How to access the bot framework in my app? - azure

I have started to check the LUIS from yesterday. I am really confused to use it.
Now, I have successfully created the LUIS app and I also have published it to the BOT framework. And I can communicate with the BOT in Azure -> BOT -> BOT Management -> Test in Web Chat.
Now, I want to create my app and access to the BOT in the Azure. Is there any SDK to connect to the BOT?
I know the endpoint "***endpoint/api/messages". How can I process some authentication to use it?

want to create my app and access to the BOT in the Azure
If you’d like to embed your bot in web application, easiest way is using with Web Chat channel to enable users to communicate with your bot in websites. For more information, please check:
Embed a bot in a website
Microsoft Bot Framework Web
Chat
Besides, if your client app does not support web chat, you can also enable communication between your bot and your own client application by using the Direct Line API.
How can I process some authentication to use it?
This article is about bot authentication, please refer to it.

Related

401 unauthorized error when registered a MS Teams bot using Azure Bot

I used "Teams Toolkit [Preview]" in VS2019 to develop a MS Teams bot. If I registered my bot via https://dev.botframework.com/bots/new, I can test that from MS Teams UI without problems. however when I registered the bot from Azure Bot service by using a existing Azure AD application which I created separately, I see "401 unauthorized" error message shown up in my ngrok screen and MS Team bot didn't work. Previously I used "Bot Channel registration" from Azure, it worked fine. As "Azure Bot" replaced "Bot Channel Registration" and "Azure Web Bot", I am trying to figure out why "Azure Bot" didn't work. Can anyone share a latest instruction how to use Azure Bot to create a MS Team Bot?
The steps to create a teams bot is essentially the same, it's just that Bot Framework Registration has been replaced by Azure Bot. The Azure Bot resource should still have all of the same Configuration and Channel registration options available.
You might find the Teams conversation bot sample helpful. Just remember that on step 4, you'll create an Azure Bot resource instead of a Bot Framework Registration resource.
You might also check for common pitfalls, such as forgetting to add /api/messages in the configuration in Azure, pointing ngrok to the wrong port, or typos of appId or other credentials in the bot settings or Teams manifest. These easy to do mistakes can usually cause those errors.

How to authenticate a user using a teams bot using my own custom authentication service?

I have created a bot on azure and registered it in bot registration channel. Now I want to authenticate the user using the bot using my own custom authentication service hosted like https://domainname/auth.
I have no idea how to do it. I have read oauth on bot framework docs but did not find any tutorial to integrate my own authentication service
You could navigate to your Bot Channel Registration -> Settings -> Oauth Connection Settings -> Add Setting
In the New Connection Setting page, could fill in the details of your Auth provider after selecting the service provider as Generic Oauth2.
For more information you could refer to the document here to learn about configuring and using the same.

Azure bot interacting with authenticated messaging endpoint

I am developing an Azure bot for Microsoft teams, using Azure Bot Service, Bot registration channel setup. The messaging endpoint is an App Service that is authenticated with AAD login. Could some please help me understand how to call this authenticated endpoint from a bot? currently, I am testing it on Webchat and I get a 401 unauthorized error. I tried configuring the Oauth Setting in the bot as per this, but still getting 401.
Could someone please point to any concepts and documentation required here.
There is no need to enable the App service Authentication. Just follow this article to add authentication to your bot via Azure Bot service. Then logon is required when you use the bot.
Reference:
Azure AD integration with Bot Framework / teams
Microsoft Teams behaves somewhat differently than other channels in regards to OAuth and requires a few changes to properly implement authentication. Specifically an Invoke Activity is sent to the bot rather than the Event Activity used by other channels. This Invoke Activity must be forwarded to the dialog if the OAuthPrompt is being used. This is done by subclassing the TeamsActivityHandler and implementing handleTeamsSigninVerifyState. It is best advised to make use of the 46.teams-auth sample to set up OAuth in Teams.
Hope this helps.

For what is Microsoft app ID and password used for?

I am trying to deploy my Azure Bot Service but I am kinda struggling to understand for what is Microsoft app ID and password used for? Can someone explain me these terms?
I was trying to find the answers online but unsuccessfully.
Thank you for any help.
This is the identity of the Bot Service.
You will notice in the App registrations of Azure Active Directory (AAD) that your Bot Service is in there. This is to give you the ability to Authenticate, Authorize and Audit (AAA) the Bot Service.
For example, you may want to provide access for your Bot Service to other services in your subscription, or other subscriptions also using the same AAD.
And so, the app has a set of credentials which it can use. The concept is similar to Managed Service Accounts in Windows Server.
The Microsoft app ID and Password are used to register the bot with the Azure Bot Service.
After you register it, those credentials will be used by the bot connector to authenticate the calls to your Bot's service and allow you to configure the bot with the different available channels.
Bot security is configured by the Microsoft App ID and Microsoft App Password that you obtain when you register your bot with the Bot Framework. These values are typically specified within the bot's configuration file and used to retrieve access tokens from the Microsoft Account service.

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.

Resources