Bot Framework Emulator Error: POST 500 directline postActivity - bots

I am trying to connect Microsoft Bot Emulator to my remote bot in Azure.
When I run my bot locally it works as expected however when I set a new configuration to connect to "Web app bot" in Azure I get error as below
[16:05:17]Error: The bot is remote, but the service URL is localhost.
Without tunneling software you will not receive replies.
[16:05:17]Connecting to bots hosted remotely
[16:05:17]Edit ngrok settings
[16:05:17]->messagehi
[16:05:17] POST 500 directline.postActivity
I have tried different options in ngrok setting and followed this post (Bot Emulator gets POST 500 directline.postActivity). However, I am still getting the error. Below is the log details in emulator inspector-json.
"{\r\n \"message\": \"An error has occurred.\",\r\n \"exceptionMessage\":
\"An error occurred while sending the request.\",\r\n \"exceptionType\":
\"System.Net.Http.HttpRequestException\",\r\n \"stackTrace\": \" at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task <>c__DisplayClass11_0.<<SendAsync>b__1>d.MoveNext()\\r\\n--- End of stack
trace from previous location where exception was thrown ---\\r\\n at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\\r\\n
Expected:
how to connect with the remote bot setting a endpoint in bot framework emulator?
where to find the "**Azure Bot Service Configuration details as in the image below"?

You can’t use the Azure supplied messaging endpoint for your bot (“xxxxxx.azurewebsites.ner/api/messages “) in Emulator. Emulator is meant for testing your locally stored bot. However, you can connect your local bot via an ngrok tunnel to your Azure hosted bot to access external services and channels. This allows you to test your code before publishing your bot to Azure.
First, use ngrok to create a tunnel (you can change the port, as needed). To create that tunnel, run this cli command:
ngrok http 3978 -host-header="localhost:3978"
This will produce a forwarding (i.e. tunneling) address that will look something like this:
https://h8g56dq.ngrok.io
Copy the “https” address.
Next, replace the messaging endpoint in your Azure hosted bot using the above address with “api/messages” appended to it. It should look like this once entered:
https://h8g56dg.ngrok.io/api/messages
In Emulator, set the address to the above. Enter your AppId and AppPassword, as well, or you will receive a 401 Unauthorized status code.
At this point, with your local bot running, you will be able connect via Emulator.
Hope of help!

Related

Azure chat bot app service throws 403 forbidden in log when chatting with test in web chat

I'm trying to get to work azure bot app service with Luis which is connected to azure bot service. But when I messaged through the test in the web chat window it shows a bug saying that there is a bug in the code. But it's working fine with the bot emulator. When I monitored the app service log it shows as Response status code does not indicate success: 403 (Forbidden). .But I have added LUIS appid, LUIS host name, and LUIS key as application settings for the app service. Have anyone faced this error before.

Hosting bot locally on IIS

First of all I know that there are similar questions like this, but by going over all of them I realized that not single one contains all the steps to host bot on local IIS, which is why I am asking this question to collect all the info in one place. So please before flagging this as duplicate take a moment to try answer this question once and for all for everyone first.
Now that said. I have created a bot using the Bot Framework Composer and successfully published it to the Azure. Everything is working fine, but I would like to move it away from Azure to on-prem IIS server. By looking around I was only able to find these somewhat comprehensive Chinese instructions.
Steps that I did:
Install IIS
Install .NET Core Windows Server Hosting Bundle from here
Created new AppPool and set it to No Managed Code
Downloaded bot from FTP on Azure and stored in local folder
Created new website on port 8080 and pointed it to the local folder
After this I am able to reach website that is telling me that the bot is ready for use on http://localhost:3978/api/messages. But when I try to connect to it by using Bot Framework Emulator it is unable to connect and I am getting error
POST 400 directline/conversations//activities
By looking at the netstat I can see that there is actually nothing running on port 3978 which leads me to believe that the IIS is running just the website and not bot itself. Any idea what I am doing wrong?
You mentioned in 5th point that
Created new website on port 8080 and pointed it to the local folder
but you are checking the bot is running in http://localhost:3978/api/messages which is the visual studio when you run this endpoint creates i think.
can you check the endpoint with port 8080 endpoint.
I think you need a https endpoint to make the bot work and also you need to enable that IIS endpoint with public accessible in internet so that you can connect it in the bot channel registration or Azure Bot channel.

Upgrade to WebSocket is required. Error when browse to folder api messages for bot deployed in azure

I have created a LivePerson Bot for handoff as per sample code. It works fine when I run it locally from emulator but. When I deploy it in azure, My messages from Liveperson agent to Azure Bot are not reaching to bot. At the same time I also get the error "Upgrade to WebSocket is required" when I browse URL api/messages of a deployed bot. Can anybody help me here. What can be probalble reasons?
Live Person proxy bot sample can be found here.
https://github.com/microsoft/BotBuilder-Samples/tree/main/experimental/handoff-library/csharp_dotnetcore/samples/LivePersonProxyAssistant
Best Regards
Check this setting in the WebApp configuration:

Connection issue with chat bot deployed on AWS

I have deployed a Node.js bot (code from Github sample) on AWS and have configured CosmosDB on Azure. I also have configured ports to allow all incoming and outgoing traffic on AWS.
Now, if I run the node server on local and use emulator to communicate, I receive messages from the server. If I use node server running on AWS to connect, I get an error as attached:
On emulator I see this - Error: The bot is remote, but the callback URL is localhost. Without tunneling software you will not receive replies.Connecting to bots hosted remotely
How do I resolve this? Do I need to install ngrok on EC2 machine as well?
Update 1: I have installed ngrok on local machine where I am running emulator.

Hosting Microsoft BOT on Enterprise Cloud?

We are trying to host the BOT on the Enterprise server IIS server which is an internet server visible to Microsoft and other outside public domains.
So, after hosting the BOT on the enterprise cloud server we would get an endpoint ex: https://myenterpriseserver.com/api/messages.
Can I use the above endpoint to register the bot in the microsoft's dev.botframework.com?
Please help, as we are planning for a large scale implementation of the BOT.
Thanks,
Mahesh
As long as the server has a SSL Certificate it should work assuming you deploy the bot correctly. Test it out first by using the Bot Emulator to see if you can send a receive messages from a computer in your system's network. Next try registering the bot on Microsoft's Bot Framework and seeing whether Microsoft's Bot Connector service can connect to the bot successfully.
Your system/intranet may block outside messages from Microsoft in which case you will have to change some settings, etc. with your firewall. This GitHub Issue follows an issue with white-listing Microsoft's Bot Connector service.

Resources