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 docs 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'".
So any ideas how to retrieve chat ID or chat members on OnTeamsMessagingExtensionSubmitActionAsync
?
So now i wanted to try a different approach using the solution provided by Dejan Janjušević :
Now when trying to add the bot to the conversation I receive the following error :