Connect Bot Framework Emulator to dockerized bot

844 Views Asked by At

I've trouble to understand the process to connect the Bot Framework Emulator to a bot, that runs within a local Docker container.

I created a (NodeJS) bot with the help of the Bot Framework Composer. I can start the bot with the IDE and connect to it via the Bot Framework Emulator successfully:

  1. Start chatbot via Bot Framework Composer
  2. Verify chatbot connect in Bot Framework Emulator

Next, I put the application into a Docker Container, exposed the port 3978 and started it locally again. I can successfully verify, that the container is running

  1. Verify running Docker Container on CLI

I can additionally verify, that the bot application is running in the container and that is accessible by calling the endpoint localhost:3978/api/messages in my browser.

For me it seems, that the bot is running in the Docker container, because there is a statement, that a route does not exist (understandable, because GET api/messages is not implemented)

  1. Verify if bot is running within the Docker container

I then created a new endpoint configuration in Bot Framework Emulator to connect to my locally deployed bot in the Docker container:

  1. Add endpoint configuration to dockerized chatbot

Now the issue appears: If I open the endpoint connection, I receive a 500 error (connection refused).

  1. Verify Bot Framework emulator output

Does someone have an idea, what's actually going on here?

What's the difference between:

  • starting the bot with "npm run dev" (= bot is available at http://localhost:3978/api/messages) and
  • starting the bot with a Docker container (= bot is available at http://localhost:3978/api/messages)

I found following issue on GitHub, but this didn't help: https://github.com/microsoft/BotFramework-Emulator/issues/356

It seems that the user here was one step further than me, because my setup already fails during connection time and in the GitHub issue the user had issues "sending" messages to a already connected bot.

Thanks in advance for any guidance here!

2

There are 2 best solutions below

0
On

This is an old question, but I had the same problem. Here is how I fixed it if that can help someone:

In your docker-compose.yml config, you need to expose the port running your bot inside your container to your localhost, so that the Bot Framework Emulator can talk to it

ports:
      - "3978:3978"

Then you also need to let your bot see what's running on localhost, to respond to the Bot Framework Emulator. The following line lets you connect to things running on your http(s)://localhosthost:(port) by calling http(s)://host.docker.internal:(port) from within your container. See documentation

extra_hosts:
      - "host.docker.internal:host-gateway"

Finally, in your Bot Framework Emulator settings:

  • Tick Bypass ngrok for local addresses
  • Set localhost override to host.docker.internal
  • Save

You should then be able to connect to Open Bot

  • Bot URL: http://localhost:3978/api/messages
  • Leave everything else blank
  • Connect
0
On

What help me.

Docker Compose settings

ports:

  • '3334:80'

extra_hosts:

  • "localhost:host-gateway"

For test I use Bot Framework Emulator