Search code examples
botframeworkngrokdirect-line-botframework

Microsoft Bot Framework - Building and debugging a client locally using ngrok


I've built a simple bot using the Microsoft Bot Framework. I now want to build a client to embed in my Mobile App. When using the Direct Line API to send a message to my bot I get a 500 error which doesn't occur through other channels.

To debug this I am attempting to run the bot on localhost and expose the port using ngrok so it can be accessed by the Direct Line API. The bot runs fine locally and processes requests fine when they are made to localhost. However when the same request is made to the temporary url created by ngrok when exposing the port, I get a 400 Bad Request error.

Has anyone run in to this problem or have some advice on how to solve it?


Solution

  • I've solved this now. Apparently the bot doesn't like it when the host header is not as expected. To solve this I exposed the port using the following ngrok command:

    ngrok http [port] -host-header="localhost:[port]"
    

    Where [port] is the port that the bot is running on.