1

I have an app containing a bot on Microsoft Teams, built using the bot-framework. I need my application to be able to let users send message to a specific channel and thread. I can do this with my bot using the "proactive messaging" ability, but the message is then send by the bot, not the user. Is there any way to achieve this as if the user sent the message?

Itay Davidson
  • 55
  • 1
  • 6

1 Answers1

1

You don't need to use the bot.

Just try this Microsoft Graph API endpoint (beta version):

POST https://graph.microsoft.com/beta/teams/TEAM_ID/channels/CHANNEL_ID/chatThreads
{
 "RootMessage": {
    "body": {
       "contentType": 1,
       "content": "Hello World!"
      }
  }
}

Remember that you need to implement the Authentication on behalf of a user.

Allen Wu
  • 15,529
  • 1
  • 9
  • 20
  • looking in microsoft's documentation for that endpoint (https://developer.microsoft.com/en-us/graph/graph/docs/api-reference/beta/api/channel-post-chatthreads) it seems that it's not supported for Application permission type, which means I can't use it in my app. Is there a way to bypass that? or maybe another approach to achieve my goal? – Itay Davidson Oct 29 '19 at 10:41
  • You *cannot* do this through the Botframework SDK and *must* use the Graph API. Ensure you use the `Group.ReadWrite.All` permission (currently only works for Delegated work/school accounts). So long as your App Registration has the permissions, you should be able to use the [token from here](https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/46.teams-auth/Dialogs/MainDialog.cs#L56). Unfortunately, I can't test this due to permission restrictions, but it *should* work. – mdrichardson Oct 29 '19 at 17:44
  • Your requirement is to send message on behalf of a user. So what you actually need is Delegated permission rather than Application permission. – Allen Wu Oct 30 '19 at 07:40