Reputation: 57
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:
Upvotes: 2
Views: 1957
Reputation: 6418
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!
Upvotes: 2