New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to run WebChat locally and talk directly to the locally hosted bot? #243
Comments
WebChat cannot talk directly to a bot. It requires a Direct Line endpoint. There is some talk about adding a Direct Line endpoint to the Emulator, which is the best way I can think of to hook WebChat up to a local bot. Of course the Emulator itself runs a WebChat instance, but I understand you may wish to test WebChat in a website. |
Thanks for the reply @billba . Yes, I wanted to run a WebChat in a website and talk directly to the bot avoiding the BotConnector. |
Can you say a little more abut why you want to do this? |
I'm developing a bot which should be mainly used in an intranet and hence not exposed to the outer world (in the moment). |
Unfortunately that is not currently a supported scenario. You would need to build your own Direct Line connector. |
However it's worth saying that even an Intranet bot can be hosted on the Internet. You control which clients have access, so it would still be private to your employees. |
Yup, I understand that this is a widespread requirement. But any solution will not be in WebChat itself, whose whole purpose in life is to be speak Direct Line with BotBuilder bots. What you need, as I mentioned above, is a Direct Line connector for BotBuilder bots. |
@billba Could you please elaborate what you mean with DirectLine connector? As far as I understand, DirectLine API connects to BotConnector. Once, on the right side which connects different channels with BotConnector and on the left side which connects BotBuilder bots with BotConnector. Still, if I control over what clients have access, BotConnector sees the whole communications because it's the man in the middle. P.S. Merry Christmas 😃 |
@pefi1011 and @billba....so for me..if there was a way to take the "botframework-emulator" and "webenize" it that would take care of things. I have my Bot build through "botbuilder" and hosting my Bot internally ... I just need to get a front-end to it. I played around some more with [BotFramework-WebChat] trying to figure out the best way to get the UI to interface with my bot...still working around with the DirectLine stuff. I just wanted to toss out my "user story." |
@pefi1011 as I understand it there is a BotConnector for each channel, e.g. Skype, Slack, Facebook Messenger. There is also one for DirectLine, which is essentially a generic channel used by custom clients and also WebChat. You are correct: BotConnector is a man in the middle. Of course that's also true for e.g. Facebook and any other messaging system that doesn't do end-to-end encryption of messages. So what you (and @forensicsguy20012004) want is a version of the Direct Line BotConnector that you can run on your Intranet. I totally get this scenario. I just don't have a solution for you at the moment, and whatever that solution is will not be part of WebChat. |
Reopening this issue to make it more visible. |
We are also looking at the emulator and seeing if the same can be used to emulate a DirectLine endpoint for webchat clients to hook into.
We are currently trying to do this. If anyone here makes a breakthru, please do share. Optional Notes |
@abhishan This is the approach we are looking at - extracting the Direct Line connector out of the Emulator into its own project that can be run independently. |
@abhishan I hope it works. I have used the emulator as a state endpoint in the similar manner. |
@siddiq-rehman Kindly share the code or the steps how you achieved this. Especially the security issues. I have tried to expose the emulator server to a stand alone webchat window, but I faced the following issues:
Still struggling :( Any help would be appreciated. |
@abhishan I have used emulator as a state end point in the bot server. I have made changes in chatConnector.js. Wherever the bot server is making a request to the emulator for the state of conversation, there I have bypassed the loop for getting the accesstoken from "https://login.microsoftonline.com/common/oauth2/v2.0/token". Since the changes are confined only to bot server it was not a difficult task. But here i tried the same way in webchat client code, so whenever posting the messages i have removed the authorization in the header. But unfortunately it didnt work :( Still I am too working on it. |
I need to authenticate my user in bot using cookies , already stored in my domain I have apis to get the user details , just dont want to ask user to sign in again. How can I implement it , my current website runs on azure web app Thanks |
Hi, I am not sure about that, but one thing that I can suggest is, there is a user variable in index.html to which you can pass your cookie. when you check the req.body in ChatConnector file of bot builder module, you can see your user details passed. This is the basic idea i got. Please reply back if you got any other option. |
First of all, this sort of question belongs on StackOverflow. @siddiq-rehman That's not really what the A better approach is to use the backchannel to send authentication information from your web page to your bot. |
@billba Thanks for the correction. |
Hi , |
@siddiq-rehman @abhishan @billba |
Does anyone find a solution at this time ? |
I think no one able to find solution for this so far... |
Any solution found for intranet bots |
I have achieved this (testing local webchat on local hosted bot). To do this, you need to:
This will route your chatbot UI back to your localhost instance :) |
Dear soonwonng Good that you have achieved it. Could you please share some code or steps to configure this. Thanks |
Amazing, Great stuff soonwong, could you please elaborate or have any reference WEB URL which I can follow to run the ngrok... Thanks |
Righto. On my local computer, I do the following:
I then locate ngrok.exe (you will have it if you have successfully set up the BotFramework Emulator). I run the command I then log on to the https://dev.botframework.com portal:
Presto! Before this is done, your web traffic will look like: After this, it should look like: |
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? |
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, @maheshksingh @mohdkhan786 I've created an unofficial testing package that allows you to emulate the connector locally: |
Hello Ryan.. I am still struggling to get a proper solution.. Could you please elaborate your solution please... Thanks for the help... |
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. |
@maheshksingh The right place to ask questions about Ryan's solution is that GitHub repo: https://github.com/ryanvolum/offline_dl |
Hello Ryan |
For me it is getting error when I run 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 again, please go to that repo to ask questions. This repo is for WebChat itself. |
another option is implement a customer middle ware, which replicates direct line protocol. you can point to your own implementation of directline protocol |
@telkomops of course you can put a Direct Line endpoint on anything. Ryan's repo is middleware that puts a Direct Line endpoint on any bot using Bot Builder. |
Is there any update on this issue. I want to create a client that talks with a chatbot hosted internally. |
There are no updates. I again recommend you look at https://github.com/ryanvolum/offline_dl |
Hello there... The way we achieved it is... We deployed the bot on a enterprise internal server which is open to receive and send requests to Microsoft bot URLS where the bot is registered... and it works |
@maheshksingh you implemented in .NET or node.js. Because both have different ways to implement. |
I have some demo code running at https://github.com/compulim/docker-bot. Since we recently refactored some code from Bot Emulator, now you can run the emulator server (a.k.a. Emulator Core) from CLI. The demo in my repos use 3 Docker containers:
Just |
Why is this issue closed? We need to debug an activity that we send from the webchat and are not able to debug it locally. Will there be a convenient way to do it in the future? |
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.
The text was updated successfully, but these errors were encountered: