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.

Prerequisites

Configure your bot in Azure

  1. Open the Azure portal.
  2. Open the Azure Bot resource blade for your bot.
  3. Open Channels and select Microsoft Teams:
    1. Read and agree to the terms of service.
    2. 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.
    3. Select Apply.
  4. 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]

Test your bot in Teams

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, is not recommended. Doing so severely limits the functionality of a bot. Bots in production should be added to Teams as part of an app.

  1. 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.
  2. 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 is re-enabled. This invalidates all 29:xxx and a:xxx IDs that the bot may have stored for proactive messaging.

Publish your bot in Teams

For instructions on how to publish your app, see Distribute your Microsoft Teams app.

Additional information