Bemærk
Adgang til denne side kræver godkendelse. Du kan prøve at logge på eller ændre mapper.
Adgang til denne side kræver godkendelse. Du kan prøve at ændre mapper.
When testing your bot, you need to consider both the contexts you want your bot to run in, and any functionality you add to your bot that requires data specific to Microsoft Teams. Ensure that the method you choose to test your bot aligns with its functionality.
Use Microsoft 365 Agents Playground to test and debug your bot locally without uploading an app to Teams. Use the Teams client to validate the full functionality of your bot with real Teams data.
Test by uploading to Teams
The most comprehensive way to test your bot is by creating an app package and uploading it to Teams. Uploading the app package to Teams is the only method to test the full functionality available to your bot, across all scopes.
There are two methods for uploading your app:
- Use Developer Portal for Teams.
- Create an app package manually, and then upload your app.
Note
To alter the manifest and re-upload your app, delete the bot before uploading the altered app package. To test the bot, enable custom app upload in Teams. See enable custom app upload.
We don't recommend uploading multiple apps with differing content under the same bot ID. This could lead to unpredictable bot behavior. Remove or uninstall any prior versions of the apps, ensuring only the latest version is uploaded. If the apps share the same bot ID, assign the necessary permissions in the app package. Additionally, activate both apps in the app permission policy and the managed apps, ensuring they aren't blocked. Failure to do so might result in issues during app usage.
Debug your bot locally
If you're hosting your bot locally during development and want to test it in the Teams client, use dev tunnels. You don't need a tunnel when testing with Agents Playground.
Install the dev tunnels CLI and sign in:
devtunnel user loginStart your bot locally, then run the following command in a separate terminal to host a tunnel. Replace
3978with the port your bot uses:devtunnel host -p 3978 --protocol http --allow-anonymousThe
--allow-anonymousoption allows the Teams service to reach your local bot through the tunnel. Your bot must still validate incoming requests.Update your bot's messaging endpoint to use the HTTPS tunnel URL shown under Connect via browser, followed by your bot's messaging route, such as
/api/messages.
Note
- If the tunnel URL changes when you restart the tunnel, update your bot's messaging endpoint to use the new URL.
- The tunnel must remain running while you test your locally hosted bot in Teams.
Test your bot without uploading to Teams
Use Agents Playground for local testing without installing your bot as an app in Teams. You can also talk to a registered bot directly by ID for basic testing. These options don't replace testing the full functionality of your bot in the Teams client. To fully test your bot, see test by uploading to Teams.
Use Microsoft 365 Agents Playground
Microsoft 365 Agents Playground provides a local environment for testing bot and agent-based apps. Use it instead of Bot Framework Emulator to send messages, inspect activities, render Adaptive Cards, and simulate Teams events with mock data. Agents Playground supports personal, team, and group chat scopes. You don't need a Microsoft 365 developer tenant, app registration, custom app upload permissions, or a tunneling service to use it.
Prerequisites
- Install a supported version of Node.js.
Test and debug in Agents Playground
The following steps apply only to bot projects created using Microsoft 365 Agents Toolkit and configured for Agents Playground. If your project wasn't created using Agents Toolkit, use the command-line workflow instead.
Before you begin:
- Install Visual Studio Code.
- Install the latest prerelease version of Microsoft 365 Agents Toolkit.
- If your existing Agents Toolkit project doesn't have an Agents Playground debug configuration, follow Debug an existing app with Agents Playground.
- Open your bot project in Visual Studio Code.
- Set breakpoints in your bot's message or activity handlers.
- Open Run and Debug (
Ctrl+Shift+D) and select Debug in Microsoft 365 Agents Playground (Preview) from the debug configuration dropdown. - Press F5 to start debugging. Agents Toolkit starts the local services and opens Agents Playground in your browser.
- Send messages to your bot and inspect its responses. When execution reaches a breakpoint, use the Visual Studio Code debugger to inspect variables and step through your code.
- Use activity triggers to send mock events, such as a member joining a conversation.
Test using the command line
You can use the Agents Playground CLI with a locally running bot without creating a project using Agents Toolkit. For more information about the CLI and message endpoint settings, see Understand Agents Playground.
In your bot project's directory, install Agents Playground:
npm install @microsoft/m365agentsplaygroundStart your bot locally using your project's startup command or IDE debugger. Note its message endpoint, such as
http://localhost:3978/api/messages.In a separate terminal, open the same project directory and launch Agents Playground:
npx teamsapptester start --app-endpoint http://localhost:3978/api/messagesReplace the endpoint URL with your bot's local message endpoint. If your bot requires authentication, configure Agents Playground for authentication.
In the browser window opened by Agents Playground, send messages to your bot and inspect its responses. To step through your code, use your IDE debugger with the running bot process.
Note
Agents Playground uses mock data and doesn't process your Teams app manifest. It doesn't support all Teams experiences, including tabs, message extensions, single sign-on (SSO), mobile, or meetings. For these scenarios and final validation with real Teams data, test your bot in Teams. For more information, see Agents Playground limitations.
Talk to your bot directly by ID
Important
- Talking to your bot by ID is intended for basic testing purposes only. Any Teams-specific functionality you add to your bot fails to work.
- Users can't chat with bots that aren't connected to a Microsoft Teams app such as Azure bots created through the Bot Framework or Power Virtual Agents. We recommend you to create a new Teams app connected to the Azure Bot using the Developer Portal, publish it to Teams, and allow users to install the app using the app permission policies. If you want to test the app, you can assign users an app setup policy that allows uploading custom apps and chat with the Azure bot through a direct link to a chat.
Initiate a conversation with your bot by using its ID. When a bot is added through one of these methods, it isn't addressable in channel conversations, and you can't take advantage of other Teams app capabilities like tabs or message extensions. Initiate a conversation in one of the following ways:
On the Bot Dashboard page for your bot, under Channels, select Add to Microsoft Teams. Teams launches a personal chat with your bot.
Directly reference your bot's app ID from within Teams:
Go to Bot Dashboard > Details and copy the Microsoft App ID for your bot.
Open Microsoft Teams, on the Chat pane, select the New chat icon. In the To: filed, enter your bot's Microsoft App ID.
The app ID must resolve to your bot name.
Select your bot and send a message to initiate a conversation. Alternatively, you can paste your bot's app ID in the search box in the top left in Teams. In the search results page, go to the People tab to see your bot and to start chatting with it.
Note
For Teams to refer to your bot's app ID, enable custom app upload.
Your bot receives the conversationUpdate event as you add the bots to a team, without the team information in the channelData object.
Block a bot in personal chat
Users can choose to block your bot from sending personal chat messages. They might toggle this by right-clicking your bot in the chat channel and choosing Block bot conversation. This means, your bots continue to send messages, however, the user doesn't receive the messages.
Remove a bot from a team
Users can delete the bot by choosing the trash-can icon on the bots list in their team's view. This only removes the bot from that team's use. Individual users can still interact in personal context. Users can't remove or disable bots in personal context.
Disable a bot in Teams
To stop your bot from receiving messages, go to your Bot Dashboard and edit the Teams channel. Clear the Enable on Microsoft Teams option. This prevents users from interacting with the bot, however, it's still discoverable and users can add it to Teams.
Delete a bot from Teams
To remove your bot completely from Teams, go to your Bot Dashboard and edit the Teams channel. Choose the Delete button at the bottom. Deleting a bot from Teams prevents users from discovering, adding, and interacting with your bot. Deleting a bot from Teams doesn't remove the bot from other user's Teams instances, however, it stops functioning for them as well.