When invoking a messaging extension in Teams, the conversation Id from Activity can't be used as a chat Id parameter for Graph API
See original GitHub issueVersion
Using v4.6.3 Nuget packages
Describe the bug
In Teams, when invoking a compose messaging extension from a private 1:1 conversation between two people, calling the Graph API action https://graph.microsoft.com/beta/chats/<conversation-id>/members
with a conversation ID obtained from ITurnContext<IInvokeActivity>
in OnTeamsMessagingExtensionQueryAsync
causes HTTP error 400 “Bad request” with no additional description.
To Reproduce
Steps to reproduce the behavior:
- In Teams, start a 1:1 private conversation with another person
- Invoke an action-based messaging extension
- In a Teams application, handle the messaging extensions via
OnTeamsMessagingExtensionQueryAsync
method - In that method, take the conversation Id from
turnContext.Activity.Conversation
object and after obtaining a valid access token usingbotAdapter.GetAadTokensAsync
, use that token and the above Conversation Id to call the Graph API actionhttps://graph.microsoft.com/beta/chats/<conversation-id>/members
- Observe the error “Bad Request”
Expected behavior
The expected behavior is to have https://graph.microsoft.com/beta/chats/<conversation-id>/members
return the list of members of a Teams conversation identified by the conversation Id obtained from the activity.
Additional context
For additional context, please take a look at the previous issue: https://github.com/microsoft/botbuilder-dotnet/issues/2976 and the StackOverflow question: https://stackoverflow.com/questions/58984349/when-invoking-a-messaging-extension-can-the-conversation-id-from-activity-be-ma
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
The conversationId you’re getting in this instance is encrypted, and cannot be used to make Graph calls. The messaging extension is personally scoped, so there is no guarantee your app is installed in that context and approved to access additional information.
For a messaging extension with an action command, you also should be handling either the fetch task or submit action events. You can then respond to the fetch task with a request to install your conversational bot, and use the bot APIs to get the roster once it is installed. See: https://docs.microsoft.com/en-us/microsoftteams/platform/resources/messaging-extension-v3/create-extensions?tabs=typescript#request-to-install-your-conversational-bot
Hi - unfortunately no, it isn’t possible to add the bot as part of the search messaging extension. You could consider using a messaging extension with an action command triggered from a message instead of a search extension. That would send the necessary information to your bot for processing, but you’d have to build your own search results screen.