简体   繁体   中英

Microsoft Teams App - Post Notification via Bot

I have a Microsoft Teams app. At this time, the app is in development. I do not want to Submit the App for approval yet. However, I do want to integrate a notification-only bot into my app. Currently, I'm trying to test notifications for this app via this bot. However, I'm stuck.

From my understanding, to post a notification, I need to:

  • Get an access token
  • Get a bearer token for my Bot
  • Start a Conversation
  • Post a message

Please let me know if I'm wrong in any of this. Either way, I'm stuck on step 1. When attempting to get an access token from https://login.microsoft.com/botframework.com/oauth2/v2.0/token , I receive an error that says:

Application with identifier '{guid}' was not found in the directory 'botframework.com'. This can happen if the application has not ben installed by the administrator of the tenant or consented to by any user in the tenant.

Since I've installed the app from the Test and Distribute tab using the Install button in the App Studio, I assume this meets the need that I, a user in my tenant, has consented to use the app. However, I guess since I haven't submitted the app to the store, I can't get a token via https://login.microsoft.com/botframework.com/ . Is this true? If it is true, is there another endpoint I should be using? How do I get a token for a bot in a Team App that I am actively developing / testing?

A Microsoft BotFramework Bot always needs to have an App ID and an App Password when securing the connection. This ID and Password are registered in Azure Portal (which will pass the information to botframework.com).

You can test your Bot locally without ID and Password, but when trying to integrate other channels like MS Teams, you will need to configure these ID and Password...

Normally you would do this by passing them to your ICredentialProvider :

services.AddSingleton<ICredentialProvider>(provider => new SimpleCredentialProvider(appId, appPassword))

You do not need to publish your Bot in any way. Just create an App Registration in Azure Portal and use the App ID and Password.

Always remember that a Teams App and a BotFramework Bot have nothing in common. The BotFramework is channel agnostic. Only the MS Teams app knows that there is a Bot with your App ID (configured in manifest.json).

The connection between MS Teams ( emea.ng.msg.teams.microsoft.com ), BotFramework ( token.botframework.com ) and your Bot ( xxx.azurewebsites.net or even ngrok...) is secured via the App ID and the Password. So never ever tell anyone what your App Password is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM