Connect a bot to Microsoft Teams
APPLIES TO: SDK v4
You can configure your bot to communicate with people via Microsoft Teams. This article describes how to create a Teams app in Teams, connect your bot to your Teams app in Azure, and then test your bot in Teams.
- An Azure subscription. If you don't already have one, create a free account before you begin.
- A bot published to Azure that you want to connect to Teams.
- A developer tenant in Teams with custom app uploading or sideloading enabled. For more information, see Prepare your Microsoft 365 tenant.
- A valid Teams app package. For more information, see Upload your app in Microsoft Teams.
- Open the Azure portal.
- Open the Azure Bot resource blade for your bot.
- Open Channels and select Microsoft Teams:
- Read and agree to the terms of service.
- On the Messaging tab, select the cloud environment for your bot. For more information, see the Post build section of Plan your app with Teams features.
- Select Apply.
- Select Get bot embed code, locate the embed code for Teams, and then copy the https part of the code. For example,
https://teams.microsoft.com/l/chat/0/0?users=28:b8a22302e-9303-4e54-b348-343232
. You can use this code to test the bot in Teams.
Tip
- The Calling tab supports the Teams calling feature. For more information, see Register calls and meetings bot for Microsoft Teams.
- The Publish tab contains information about how to publish your Teams app to the Teams Store.
- The Microsoft Azure operated by 21Vianet does not support the Get bot embed code feature. To test the Teams channel, create the Teams app and deploy it using the steps mentioned below.
Bots in production should be added to Teams as part of a Teams app. For more information, see Test your app.
Important
Adding a bot by GUID, for anything other than testing purposes, isn't recommended. Doing so severely limits the functionality of a bot. Bots in production should be added to Teams as part of an app.
- In your browser, open the URL you copied from your embed code, then choose the Microsoft Teams app (client or web) that you use to add the bot to Teams. You should be able to see the bot listed as a contact that you can send messages to and receive messages from in Microsoft Teams.
- Interact with your bot in Teams.
Tip
Use one bot channel registration per environment, since your endpoint changes when you switch between local development, staging, and production environments.
Deleting the Teams channel registration will cause a new pair of keys to be generated when it's re-enabled. This invalidates all 29:xxx and a:xxx IDs that the bot may have stored for proactive messaging.
For instructions on how to publish your app, see the Teams overview of how to Distribute your Microsoft Teams app. It and the associated articles cover how to:
- Choose and configure install options for your bot
- Create your Teams app manifest, icon, and package
- Upload your app to Teams
- Publish your app to your org or to the Teams store
- For more about Teams app development, see Build apps for Microsoft Teams and Get started.
- For more about creating bots for Teams, see Bots in Microsoft Teams.
- For more about publishing and testing a bot in Teams, see Distribute your Microsoft Teams app and Test your app.
- To provide feedback and find additional resources, see Microsoft Teams developer community channels.