How to attach a teams bot to a specific channel?

Robert Stevens 20 Reputation points
2024-06-19T07:38:17.89+00:00

Hi, I have a Teams Bot Custom application (i.e. not published on the store) and we have a customer dashboard (web app) that programatically (using MS Graph API) create's a channel for a team, publishes the bot app to their team's app catalog, and adds the bot to their team. This all works.

The above installation method I will refer to as "auto install".

From my understanding the bot is then available to all the channels within the team - is this correct?

I also believe the TeamsBotInstallation defaults to the "General channel" when installing it to a team - is this correct?

Secondly the bot then sends the welcome message to the "General" channel (main channel in the team instead of the specific channel we created)

I am using DynamoDB to store the "bot connections" and it does show that it stores the conversation (which is representative of a TeamsBotInstallation) for the General channel, but not for the specific channel we created.

export const notificationApp = new ConversationBot({
  adapterConfig: {
    MicrosoftAppId: config.botId,
    MicrosoftAppPassword: config.botPassword,
    MicrosoftAppType: "MultiTenant",
  },
  // Enable notification
  notification: {
    enabled: true,
    store: new DynamoStore(),
  },
});

When I try to manually install the bot application to the channel in the Teams client, it doesn't do anything. No welcome message, and the connection is not saved to DynamoDB.

When I remove the app from the team in Teams, and then add it back to the channel, the bot sends a welcome message to that channel and the connection is saved to DynamoDB - everything works. I will refer to this as "manual install".

It feels that the auto installs fails to let the bot add the connection for the specific bot channel, while doing the manual install achieves this.

What else do I need to do with the auto install process allow the bot to save the connection correctly?

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
9,556 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,037 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Q&A Assist
    2024-06-19T07:38:17.9+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    When a Teams bot is added to a team, it is available to all channels within that team. By default, the bot is installed in the "General" channel of the team. To install the bot in a specific channel, you can use the Teams Graph API to add the bot to that channel. It is possible that the auto install process is failing to save the connection for the specific bot channel, while the manual install process achieves this. To allow the bot to save the connection correctly during the auto install process, you may need to update the bot's code to include the specific channel ID in the installation process.

    References: