Accessing bot in azure in android - c#

I have deployed a bot in azure. Bot is written in C# using microsoft bot framework.
I am able to communicate with it using Microsoft Bot Framework Emulator after providing the azure URL, App Id and App Secret.
How to communicate with the bot from android?
Is there a URL to communicate with it like a REST Api?

If you use a bot registered to BotFramework, you can try to configure the Web Chat channel :
Log in to Bot Framework
Go to "your bots"
Click on the bot you've registered
Click on "Edit" next to “Web Chat” in the Channels
Generate your Web Chat Secrets (a blue button)
Tick "enable this bot on web chat"
Take note of the secret and embed tag
Then, take out the link from the iframe, (you'll get something like this : https://webchat.botframework.com/embed/YourBotID?s=YOUR_SECRET_HERE )
Replace YOUR_SECRET_HERE with the secret you previously took
Then, browse the final link from your phone / anywhere.

#SandeepMenon, There is a blog which introduces how to integate Azure Logic Apps with a Bot Web App using Bot Framework API hosted on Azure and supply the sample project on GitHub.
I think you can try to refer to the blog and use the Azure Logic App as callable endpoint, then to communicate with bot from android is only implementation for calling the http endpoints from android.

Related

"There was an error sending this message to your bot: HTTP status code NotFound"

I created a bot with C# and deployed it and I keep getting error code NotFound or when tested in emulator 404.
The bot works perfectly fine locally when tested but when deployed it fails.
I've created a bot with composer and it does same thing, works locally, but then fails when deployed to Azure.
Bot config :
Bot working locally:
Bot failing remotely:
and
I have faced the same issue while creating "Web App Bot" with custom password option, sometimes this option will fail. So you can try with auto generated password option in "Web App BOT".
Please verify the following authentication details:
Microsoft AppId -> Should be use same App Id in both application & azure portal.
Microsoft Password -> Should be use same Password in both application & azure portal.
Directline Token -> Verify this token if you are connecting from front-end framework.
Messaging endpoint -> Verify this endpoint
Web App Bot is help to create all necessary service automatically for chatbot implementation and we can create the same process in another way. Please check the following steps.
Create an app service in azure ( host your chatbot application )
Create azure bot channel registration.
Link App service & bot channel registration using app service endpoint.
Validate all of the authentication details.
Note : You can test your app in azure bot emulator "Test in WebChat" section.
Reference :Azure Chatbot & Bot Framework Composer
What solved my problem was changing the Protocol Setting of the App Service. If you've deployed your bot using Bot Composer, in the resource group you will find 2 App Services - one with a 'qna' suffix and the other without. Choose the one without the 'qna' suffix.
Select the App Service --> TLS/SSL settings --> HTTPS Only --> On
ok so I found the solution:
Error (502) Bad Gateway: When trying to access chatbot deployed on Azure using WebChat channel
apparently if you deploy your bot to azure it doesn't work. But if you create a bot on azure, then deploy the bot you created to that appservice it works. The way the answer in the link describes is a little vague and not complete. To resolve my issue I created a bot in azure, and that automatically creates an app service with it. I then published the bot I created in visual studio by selecting the resource group and the appservice as my target of the bot I created in Azure. The bot I want to host then replaces the first bot, and somehow that magically fixes network issues. Apparently if you create bot in visual studio or composer and publish it as is just doesn't work, this is an issue they need microsoft needs to work on.

How do I configure an Azure Function to call the Microsoft Graph without using a user account?

I have an Azure Function with an HTTP trigger that I am developing in Visual Studio 2019. The intention is to have another application call the Azure Function, which will then call the Microsoft Graph to do some changes on users and groups. I'm using the Azure Function to control what groups and users can be changed and to provide some business logic.
The function has an app registration in Azure, with an app secret so it can be protected. However I try to submit a POST to the Azure Function, it never works. I get a 404 when trying to use Postman. If I use the Code + Test section in Azure Functions of the portal, I get "Value cannot be null. (Parameter 'clientSecret')"
If I run the code locally and call it via Postman, it works, but of course there is no Azure authentication happening for this call.
I assume I have a authentication/configuration issue somewhere, but I do not know how to go about debugging it.
If you want to call .net Core Web API from other .net Core Web API projected by Azure AD, you use the OAuth 2.0 Client credentials flow.
Regarding how to configure it, please refer to the following steps:
Register the web app
Register APP
Create Client secrets
Configure permissions to access another web api. (I use Microsoft graph for test)
Configure an application to expose web APIs(Add scope for the api)
Register the client app
Register Function APP
Create Client secrets
Configure permissions to access web API
Configure known client applications for web API application
In the Azure portal, navigate to your Web api app registration and click on the Manifest section.
1.In the Azure portal, navigate to your Web api app registration and click on the Manifest section.
2.Find the property knownClientApplications and add the Client IDs of the client applications.
For more details you could refer to this article.

Does Cortana support webhooks / calling external API's?

I've been trying out to create skills for Cortana and would like to hook it up to a .NET Core web API that I made. This web API already contains implementations for Google Home and Alexa and I would like to add Cortana communication to this web API.
Currently I've looked into the examples on the microsoft website and played around with them. The examples give me a .zip file with a pre-generated project which handles the requests, I would like to use my own web API for this.
When publishing apps in LUIS I found some info on endpoints under the Keys and Endpoint settings, but it doesn't seem to be a kind of endpoint that I'm looking for.
Is it possible to use personal Web API's to handle intent behavior similar to Dialogflow
webhooks or Alexa Endpoints for Cortana bots?
Any links or other references would be very helpful.
Thanks in advance!
Using a Bot Channels Registration, a Cortana connected skill will make POST calls to the configured Messaging Endpoint:
All Bot Framework services use industry-standard REST and JSON over HTTPS and communicate with messages based on the Bot Framework -- Activity schema. With the Cortana channel, when a POST is received at the Messaging Endpoint the code must acknowledge the call (HttpStatus 200) and send return messages within 10 seconds (serviceUrl is the base url for the destination). Your code can call into whatever other services or apis you require during that time.
The Bot Builder SDK helps enable more easily communicating with Bot Framework services, including the Cortana Connector Services.

Automatic deployment of bot service on azure using C#

I need to be able to deploy bot framework solution fully automatically from a .net web app.
The resources I am able to create with ease (using Microsoft.Azure.Management.Fluent) are:
app service plan
Web App with bot backend
azure storage
The resources that I want (and can't) are:
"Wab App Bot"
"Cognitive Service" with LUIS (this one is optional for know, but it would be really great if I can also create this kind of resource from code)
I have configured service principal with necessary rights.
You can find the code samples to create Azure app bot and Cognitive Service under the SDKs.
Azure app bot https://github.com/Azure/azure-sdk-for-net/tree/psSdkJson6/src/SDKs/BotService
Azure Cognitive Service https://github.com/Azure/azure-sdk-for-net/tree/psSdkJson6/src/SDKs/CognitiveServices
My though on this to enable the continious deployment for the bt code using GitHub or AzureDevOps, following link will help you set up the CD for the bot
https://learn.microsoft.com/en-us/azure/bot-service/bot-service-build-continuous-deployment?view=azure-bot-service-4.0
As for the LUIS application, what I end up doing is to use PowerShell / C# app to deploy the LUIS app definition using the LUIS REST api https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5890b47c39e2bb052c5b9c2f

Error (502) Bad Gateway: When trying to access chatbot deployed on Azure using WebChat channel

I am developing a chatbot using Microsoft Botframework. Bot works fine when I run it locally with emulator. How ever when I deploy it on Azure as a bot service and try to access it using webchat channel it start giving 502 error.I am tried following steps to deploy it.
Created a resource group in Azure
Created a Service Plan in azure
open url https://dev.botframework.com/ and under My bots menu item clicked "Create a bot" button
"Create a bot" page takes me to Azure Bot Service page
On Azure Bot service page I select "Web App Bot"
On clicking "Create" Azure ask me few details such as Bot Name, Resource group, App Name etc and creates a Bot
In this new Bot when I go to "Test in Web Chat" and type something it gives me a response back.
Now I took app id and secret key from Settings and add it to web config file.
Now I publish my bot from Visual Studio selecting new bot service as app service
Publishing is successful
Now when I try to access my bot in Test in Web Chat window in Azure,messages start getting failed
I have taken the web chat link from channel section and paste it on html page and updated secret key for web chat
Now when I send a message I start getting (502) bad gateway error in console.
I have deployed bots in the past as well but at that I was using dev.botframework.com for configuring bots.
This is first time I am trying to deploy it on Azure Bot service and don't know what am I missing here.
Can someone help me with this?
The error (HTTP status code 502) indicates that either the bot returned an error or the request timed out. You can go to the bot's Channels blade and click the "Issues" link for the affected channel to check the information about errors, or use Application Insights to trace error details.
Besides, if possible, you can create a new simple bot application with Bot Builder SDK in visual studio and upgrade the Bot Builder SDK for project, then deploy it to corresponding Azure app service with the following steps&diagrams, and check if new bot application can work with bot service.
After you created it, two resources: Web App Bot and App Service are created in your resource group. Something like below:
To deploy your bot application developed by Bot Builder SDK in visual studio, you can choose and publish to that corresponding app service.
Note: you can check “Remove additional files at destination” option when you deploy the bot application to your Azure web app

Categories