No ActivityHandler events raised for new messages in group chats with bot installed
See original GitHub issueVersion
4.14.1
Describe the bug
I created a group chat and installed my bot into it. I can post proactively using a connectorclient, and I get events for participants being added and removed, but there are no activities raised for new messages in the chat thread.
To Reproduce
Using graph, create a group chat and add a bot like this:
Chat c = new Chat
{
ChatType = ChatType.Group,
Topic = "Group chat:" + Guid.NewGuid(),
Members = new ChatMembersCollectionPage()
{
new AadUserConversationMember
{
Roles = new List<String>()
{
"owner"
},
AdditionalData = new Dictionary<string, object>()
{
{"user@odata.bind", "https://graph.microsoft.com/v1.0/users/"+ userID}
}
},
new AadUserConversationMember
{
Roles = new List<String>()
{
"owner"
},
AdditionalData = new Dictionary<string, object>()
{
{"user@odata.bind", $"https://graph.microsoft.com/v1.0/users/" + AppId}
}
}
}
};
//requires TeamsAppInstallation.ReadWriteForChat
Chat resp = await m_graphClientUser.Chats.Request().AddAsync(c);
m_chatID = resp.Id;
var teamsAppInstallation = new TeamsAppInstallation
{
AdditionalData = new Dictionary<string, object>()
{
{"teamsApp@odata.bind", "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/" + catalogAppID}
}
};
await m_graphClientUser.Chats[resp.Id].InstalledApps.Request().AddAsync(teamsAppInstallation);
Then, override OnTurnAsync in a bot that derives from ActivityHandler (I just left the default and set a breakpoint to inspect activities:
public class ACSBot : ActivityHandler
{
public override Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default)
{
return base.OnTurnAsync(turnContext, cancellationToken);
}
Note if you add/remove participants from the chat in Teams, OnTurnAsync (and the appropriate other events) will fire. Reactions to bot messages also fire events. If another user sends a message to the chat thread though, nothing is fired on the bot, so the bot can’t react to the new messages like it would in a 1:1 chat.
Expected behavior
I’d expect to get message activity for any other user message in the chat.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
@stevkan - it seems like this is by design, so at this point the only other assistance would be to amend that design so that bots installed to a group chat with chat.readwrite should get notified of all messages in the chat as they happen. It’s possible to do this with a change notification subscription, but it’s harder than it should be (I actually put together a blog post describing how to do this here)
Copying from https://docs.microsoft.com/en-us/learn/modules/msteams-conversation-bots/2-conversation-bots:
I think this is by-design and is a feature request: Bot on Teams should react/receive messages without explicit at-mentions.