Del via


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

  • 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.

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, 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.

  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's 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 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

Additional information