0

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'".

API Permissions All granted: enter image description here

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ć :

Operation returned an invalid status code 'Forbidden' when calling GetConversationMembersAsync for 1:1 private conversation

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

Something went wrong, please try again later. enter image description here

  • Thank you for reaching out to us We will investigate and if we require further information we will reach out. Best regards, Teams Platform – Abhijit Jul 02 '20 at 13:53
  • Your examples are a little hard to follow because you're kind of mixing Graph, Bots, and more. Let's start simple - do you have an -actual- running Bot at this point? – Hilton Giesenow Jul 02 '20 at 16:58
  • @HiltonGiesenow yes the bot is running.Well tried to retrieve the members from TeamsInfo but got Forbidden 403. Then after doing some search I come across some threads advising to use Microsoft Graph. So if there is away to retrieve chat members without Microsoft graph in 1:1 conversation please do share – user3595604 Jul 02 '20 at 17:15
  • @HiltonGiesenow question updated. – user3595604 Jul 02 '20 at 17:26
  • If it's 1-1, presumably you were trying this: https://learn.microsoft.com/en-us/dotnet/api/microsoft.bot.builder.teams.teamsinfo.getmemberasync?view=botbuilder-dotnet-stable#Microsoft_Bot_Builder_Teams_TeamsInfo_GetMemberAsync_Microsoft_Bot_Builder_ITurnContext_System_String_System_Threading_CancellationToken_ ? – Hilton Giesenow Jul 02 '20 at 17:51
  • @HiltonGiesenow TeamsInfo.GetMembersAsync is returning "Operation returned an invalid status code 'Forbidden".That's why I moved to Microsoft graph client. Even i tried to add the bot to conversation and it failed. The problem is errors returned are not quite clear and I don't understand why it is so complicated to retrieve what is obvious.Am chatting with the recipient, I can see the recipient email and I know my email.Why it can't be retrieved easily. – user3595604 Jul 02 '20 at 19:05
  • You do not get Messageid on "OnTeamsMessagingExtensionSubmitActionAsync". IT has turnContext of type IInvokeActivity. You need to capture and save the message id when you are creating message and sending the activity. After calling turnContext.SendActivityAsync(reply, cancellationToken) method you need to capture the message id. – Abhijit Jul 06 '20 at 10:02

0 Answers0