question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

Version

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:

  1. In Teams, start a 1:1 private conversation with another person
  2. Invoke an action-based messaging extension
  3. In a Teams application, handle the messaging extensions via OnTeamsMessagingExtensionQueryAsync method
  4. In that method, take the conversation Id from turnContext.Activity.Conversation object and after obtaining a valid access token using botAdapter.GetAadTokensAsync, use that token and the above Conversation Id to call the Graph API action https://graph.microsoft.com/beta/chats/<conversation-id>/members
  5. 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:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
clearabcommented, Nov 26, 2019

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

0reactions
clearabcommented, Jan 16, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - When invoking a messaging extension, can the ...
When invoking a messaging extension, can the conversation Id from Activity be matched with a chat Id from Graph API?
Read more >
Initiate actions with message extensions - Teams
A message extension is a cloud-hosted service that listens to user requests and responds with structured data, such as a card.
Read more >
Message extensions - Teams
Learn how message extensions are used, its types, and scenarios where its used on the Microsoft Teams platform.
Read more >
Bot API changes for team and chat members
In this module, learn upcoming and in-progress changes to the Bot APIs used for retrieving members of teams and chats.
Read more >
Send activity feed notifications to users in Microsoft Teams
The Microsoft Teams activity feed enables users to triage items that require attention by notifying them of changes. You can use the activity...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found