How to Connect Bot to MS Teams

Setting Up the Bot:

  1. Create an Application:
    • Go to Apps.
    • Click on the Import app and import the file. The file contains the application manifest and bot icons.
  2. Create a Bot:
    • Go to Bot management.
    • In Configure, specify the bot webhook (https://<bot_host>>/api/webhook) where the Microsoft Teams API will send incoming events.
    • In Channels, make sure the Microsoft Teams checkbox is selected.
  3. Associate the Bot with the Application:
    • Return to your application in Apps.
    • Inside the bot, go to App features → Bot → Identify your bot → Select an existing bot -> choose the previously created bot.
  4. Fill in the Bot’s Environment Variables (Developer Required):
    • MICROSOFT_TENANT_ID – Go to Microsoft Entra ID for your organization → Basic information → Tenant ID. This is needed to obtain information about the personal chat identifier with the user so that the bot can send autonomous messages (e.g., alerts).
    • MICROSOFT_APP_ID – Go to Bot management → Bot ID.
    • MICROSOFT_APP_PASSWORD – Go to Bot management → Client secrets → Add a secret. This is needed for authenticating requests between the bot and the Bot Connector service.
    • BACKEND_API_URL – Root URL of the backend API. By default, in the local developer environment, the value is http://localhost:5000/api/v1.
  5. Fill in Backend Service Environment Variables (Developer Required):
    • MICROSOFT_BOT_BASE_URL – Bot URL. By default, in the local developer environment, the value is http://localhost:3978.

Deploying the Bot in Your Organization:

  1. Go to the bot in Apps → Publish to org → Publish your app.
  2. The IT admin of the organization must approve the application (bot) publication request.
  3. App publication takes an average of 5 minutes.

If you have modified some information in the bot application in Apps, you need to deploy a new version of the bot in the organization:

  • Go to the bot in Apps.
  • Change the bot version in Basic information → Version.
  • Publish to org → Submit app update.

Adding the Bot to a Team:

How to Connect Bot to MS Teams
How to Connect Bot to MS Teams

Bots cannot be used in private channels as it is not supported in Microsoft Teams.