BotFramework-WebChat icon indicating copy to clipboard operation
BotFramework-WebChat copied to clipboard

How to run WebChat locally and talk directly to the locally hosted bot?

Open pefi1011 opened this issue 9 years ago • 47 comments

Hi, is WebChat able to (emulate BotConnector services and) talk directly to the locally hosted bot?

Right now, I'm talking to my locally hosted bot, but I have registered it and exposed it to outer world via ngrok. What should I change to enable this? Dan Driscoll mentioned something like unhooking security.

pefi1011 avatar Dec 22 '16 15:12 pefi1011

@billba Thanks for the correction.

siddiq-rehman avatar Apr 11 '17 18:04 siddiq-rehman

Hi , Anyone has got any solution for this. I am struggling with the same issue. I want to connect bot with my custom chat window UI.

sachinsbucket avatar May 04 '17 21:05 sachinsbucket

@siddiq-rehman @abhishan @billba Even I am Struggling with the same issue to enable bot completely private to organization. If someone finds a solution pls do share ..

mohdkhan786 avatar May 11 '17 10:05 mohdkhan786

Does anyone find a solution at this time ?

Nostreum avatar Jun 16 '17 08:06 Nostreum

I think no one able to find solution for this so far...

mohdkhan786 avatar Jun 18 '17 06:06 mohdkhan786

Any solution found for intranet bots

maheshksingh avatar Jul 10 '17 17:07 maheshksingh

I have achieved this (testing local webchat on local hosted bot). To do this, you need to:

  • Run ngrok locally.
  • Log into dev.botframework.com, and update the API callback URL of your bot to https://ngrock.io:xxxx/api/message

This will route your chatbot UI back to your localhost instance :)

soonwong avatar Jul 17 '17 22:07 soonwong

Dear soonwonng

Good that you have achieved it. Could you please share some code or steps to configure this.

Thanks

mohdkhan786 avatar Jul 18 '17 03:07 mohdkhan786

Amazing, Great stuff soonwong, could you please elaborate or have any reference WEB URL which I can follow to run the ngrok... Thanks

maheshksingh avatar Jul 18 '17 03:07 maheshksingh

Righto. On my local computer, I do the following:

  • Configure my webchat front end to be hosted on IIS. (e.g. https://localhost:80).
  • Configure my webchat to use the direct line API.
  • Configure my API to be hosted on IIS. I ensure that a binding to https://localhost:1234 works. Note the port number is arbitrary, I wanted it to be not port 80 to be certain of connectivity.

I then locate ngrok.exe (you will have it if you have successfully set up the BotFramework Emulator). I run the command ngrok http 1234. This will open up a tunnel via ngrok to https://localhost:1234. Use your preferred port number.

I then log on to the https://dev.botframework.com portal:

  • I locate my bot
  • I configure the bot settings
  • I change the endpoint URL from https://mybotinazure.com/api/messages/ to https://xxxxxx.ngrok.io/api/messages/

Presto!

Before this is done, your web traffic will look like: user -> webchat -> directline -> botframework -> bot API -> botframework -> directline -> webchat -> user

After this, it should look like: user -> webchat -> directline -> botframework -> ngrok -> localhost -> ngrok -> botframework -> directline -> webchat -> user.

soonwong avatar Jul 18 '17 05:07 soonwong

Geat work and nice way of telling the steps.... only one thing... how secure is it to expose the local intranet to internet thru ngrok? does it provide any security features?

maheshksingh avatar Jul 18 '17 06:07 maheshksingh

This should only be done for debugging a development environment. The tunnel will only be running so long as the command line instance of ngrok is running. If you're going to be deploying a production instance of the bot onto an intranet, you will need to find another means of connecting your bot to the botframework in Azure.

soonwong avatar Jul 18 '17 07:07 soonwong

@soonwong, @maheshksingh @mohdkhan786 I've created an unofficial testing package that allows you to emulate the connector locally:

NPM package Github Repo

ryanvolum avatar Jul 19 '17 17:07 ryanvolum

Hello Ryan.. I am still struggling to get a proper solution.. Could you please elaborate your solution please... Thanks for the help...

maheshksingh avatar Jul 19 '17 18:07 maheshksingh

have you checked out the readme? If you're not a node guy it might be a bit confusing. If you have node running on your computer you can npm install this package and run the directline command mentioned in the readme, passing in the port where you want to host your connector and the endpoint where your bot lives.

ryanvolum avatar Jul 19 '17 19:07 ryanvolum

@maheshksingh The right place to ask questions about Ryan's solution is that GitHub repo: https://github.com/ryanvolum/offline_dl

billba avatar Jul 19 '17 20:07 billba

Hello Ryan Thats great... My problem is that my bot is in. Net. Will your solution works for. Net bot also or only to node bot?

mohdkhan786 avatar Jul 21 '17 02:07 mohdkhan786

For me it is getting error when I run npm run directline 3000 localhost://127.0.0.1:3979/api/messages

May be because of firewall in company. Is there any alternative to install this with firewall.

I tried with setting proxy as well but no success

mohdkhan786 avatar Jul 21 '17 11:07 mohdkhan786

@mohdkhan786 again, please go to that repo to ask questions. This repo is for WebChat itself.

billba avatar Jul 21 '17 18:07 billba

another option is implement a customer middle ware, which replicates direct line protocol. you can point to your own implementation of directline protocol

telkomops avatar Jul 24 '17 09:07 telkomops