Forum Discussion
When I install my app to a second channel in Teams, the this.onMessage will nto trigger
I have a bot which when installed to a channel will read messages using this.onMessage, if I add another channel to the same team it will also read the messages without installing the bot on that channel.
However if a user installs the bot again, to the second channel which some users do, the second channel will not trigger the onMessage listener except when using the @botname command. I cant log errors anything because it just wont trigger. I feel like the context gets screwed up, all the other listeners fire on other channel
Any help please?
Hello markofarl,
The behavior you’re seeing is expected and results from how Microsoft Teams handles bot installation scopes.
Initially, the bot is installed at the team scope, so it is treated as a participant in all team channels. In this mode, the bot receives all channel messages through onMessage, even when users do not mention the bot.
When the bot is later installed again at the channel scope in another channel, Teams treats this as a separate installation with different messaging rules. Channel-scoped bots only receive messages when they are explicitly mentioned using @botname. As a result, normal channel messages in that channel are filtered and never delivered to the bot service, which is why onMessage does not fire and no errors or logs appear.
Other listeners such as conversation updates, member changes, or installation events continue to work because they are system events, not user message events, and therefore are not restricted by mention requirements.
This behavior is not a bug in the Bot Framework SDK or your bot code, but rather a Teams design decision related to installation scope. The recommended solution is to avoid installing the same bot in multiple scopes. For scenarios where the bot should read all channel messages, it should be installed only at the team scope, and the Teams app manifest should restrict the bot to "scopes": ["team"] to prevent channel-level installations.
In short, installing the same bot at both team and channel scope changes message delivery rules, and channel-scoped installations require explicit @bot mentions for messages to reach the bot.
3 Replies
- Sayali-MSFT
Microsoft
Hello markofarl,
The behavior you’re seeing is expected and results from how Microsoft Teams handles bot installation scopes.
Initially, the bot is installed at the team scope, so it is treated as a participant in all team channels. In this mode, the bot receives all channel messages through onMessage, even when users do not mention the bot.
When the bot is later installed again at the channel scope in another channel, Teams treats this as a separate installation with different messaging rules. Channel-scoped bots only receive messages when they are explicitly mentioned using @botname. As a result, normal channel messages in that channel are filtered and never delivered to the bot service, which is why onMessage does not fire and no errors or logs appear.
Other listeners such as conversation updates, member changes, or installation events continue to work because they are system events, not user message events, and therefore are not restricted by mention requirements.
This behavior is not a bug in the Bot Framework SDK or your bot code, but rather a Teams design decision related to installation scope. The recommended solution is to avoid installing the same bot in multiple scopes. For scenarios where the bot should read all channel messages, it should be installed only at the team scope, and the Teams app manifest should restrict the bot to "scopes": ["team"] to prevent channel-level installations.
In short, installing the same bot at both team and channel scope changes message delivery rules, and channel-scoped installations require explicit @bot mentions for messages to reach the bot.
- Sayali-MSFT
Microsoft
Hello markofarl,,
Your feedback is important to us. Please rate us:
🤩 Excellent 🙂 Good 😐 Average 🙁 Needs Improvement 😠 Poor
- Sayali-MSFT
Microsoft
Hello markofarl,
Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.