retrieve chat members bot framework

Mohamad Najia 206 Reputation points
2020-07-02T10:45:07.047+00:00

Brief explanation:
I have created an action based message extension bot in Microsoft teams.
Now if the action is triggered in 1:1 conversation, I retrieve all the parameters sent on OnTeamsMessagingExtensionSubmitActionAsync and send them to my backend web service. I also need to send the recipient email and sender email.
The issue is that am not able to retrieve members from the bot framework.

In Microsoft Learn to retrieve the chat members we should use the below code :

  GraphServiceClient graphClient = new GraphServiceClient( authProvider );  
      
    var members = await graphClient.Me.Chats["{id}"].Members  
     .Request()  
     .GetAsync();  

However, the ID is not the conversation ID or the activity ID retrieved from the ITurnContext<IInvokeActivity> turnContext

I also tried the following:

string serviceUrl = "https://smba.trafficmanager.net/emea/";
Dictionary<string, List<string>> customHeaders = new Dictionary<string, List<string>>();
customHeaders.Add("Authorization", new List<string> { "Bearer " + myToken });
var connector = new ConnectorClient(new Uri(serviceUrl), new MicrosoftAppCredentials(botClientID, botClientSecret));
var members = connector.Conversations.GetConversationMembersWithHttpMessagesAsync(turnContext.Activity.Conversation.Id, customHeaders,cancellationToken).Result.Body;

I receive "Operation returned an invalid status code 'Forbidden'".

API Permissions All granted:
11432-apipermissions.jpg

So any ideas how to retrieve chat ID or chat members on OnTeamsMessagingExtensionSubmitActionAsync?

The main question would be how to retrieve chat members in 1:1 conversation using chat bot extension messaging of type Action?

So now i wanted to try another approach following :

https://stackoverflow.com/questions/58866100/operation-returned-an-invalid-status-code-forbidden-when-calling-getconversati

Now when trying to add the bot to the conversation I receive the following error :

Something went wrong, please try again later.

11426-addbottoconv.jpg

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
788 questions
{count} votes

Accepted answer
  1. Mohamad Najia 206 Reputation points
    2020-07-07T07:30:26.98+00:00

    Okay the solution has been found with the help of Dejan Janjušević .
    Dejan Janjušević recommended to open Microsoft teams in web and check for errors.
    We discovered that groupchat is missing from the scope.
    After adding the groupchat to the scope, I was able to add the bot to the conversation and retrieve the members.
    Thank you Dejan Janjušević for your help and support.

    0 comments No comments

0 additional answers

Sort by: Most helpful