Microsoft Bot Framework Emulator and docker

Jonathan Harrison
Chatbots Life
Published in
3 min readNov 28, 2017

--

Source

In the run up to Christmas I am finding myself especially busy both at work and personally, but I thought I would make the time to write this short post.

My current side project I am working is to create a bot in Node using Microsoft’s Bot Framework; I will write more about it soon as I make more progress.

Starting out I created an Express app using Express’s generator and from there added TypeScript, linters and a dockerfile. This app successfully built and ran within a container.

With the basic app and environment all working, it was time to add the bot dependencies in (i.e the botbuilder module) and get a basic bot up and running replying with whatever a user said per Microsoft’s quickstart.

For those who haven’t used Microsoft Bot Framework, you can use an emulator to debug and test your bot outside of channels e.g. Facebook Messenger and Skype to name a few.

Issue

This is where things started to get irritating — running the bot directly with a npm script and connecting to it with the emulator worked as expected; the bot was replying with whatever I said. However when I tried to run the bot in a container, the bot wouldn’t respond to messages in the emulator.

This stumped me for a few days, why couldn’t the emulator communicate with the bot in a container. I did things like checked what ports I was exposing, tried different ports, ran in development mode, installed development dependencies as well and attached to the running container.

The only hint I got was in development mode, the bot logged that the emulator couldn't attach to a random port in the 5000 range.

Solution

After running out of other ideas, I remembered that whilst reading the Bot Framework documentation the emulator requires ngrok to be installed and configured to talk to remotely hosted bots. I thought might as well give it a go and guess what … the bot started responding from the container.

So with a lucky guess, it turns out for the Microsoft Bot Framework Emulator to work with a docker container running on your local machine, you need to have ngrok installed and configured.

--

--

Principal Software Engineer @ Tripadvisor. Formerly at Spotify, Altitude Angel and Microsoft. All opinions are my own.