Closed erlendw closed 8 years ago
You can test using the Channel Emulator. https://docs.botframework.com/en-us/tools/bot-framework-emulator/
In the link describe: How to test your own bot locally, and how to connect the emulator to the published app.
thanks
I see that the question was not specific enough. I was thinking more along the lines of writing a custom client connector without going through the Direct Line api hosted by Microsoft. I want to host my bot locally, and not have to use the direct line api.
I think code of Bot emulator can be used, It does same locally.. but its not available
Dan Driscoll briefly discussed that it would be possible to write a wrapper or something for the emulator on this podcast https://www.youtube.com/watch?v=z_JOzrEKCB4. @dandriscoll could you please elaborate on this?:)
It would be great to be able to re-create the Channel Emulator code in a mobile app - mostly to avoid the extra latency of a middleware webservice as well as to be able to support things like cards and actions in the app.
At the moment DirectLine strips out many of these features and instead sends a plain text fallback e.g. appends '(1. yes or 2. no)'.
I have to include code in my mobile app that tries to interpret these fallbacks as e.g. asking for confirmation which is a little brittle since the text may change at any time, may be different in different languages etc.
There is some documentation on the SDK (i.e. https://docs.botframework.com/en-us/restapi/authentication/#navtitle) but it seems to be from the point of view of creating a bot, not from the client side.
This is exactly why i want to connect directly as well! Running through the direct line api is so much slower than hosting the bot on a local server.
I have tried to decompile the emulator, but there is too much code to get something working quickly. If you want to try and have a look at it just download dotpeek and find the stuff you need from the install location of the bot emulator
Hopefully more people are interested in an actual direct line to the bot, instead of going through the api :)
The short answer is this: yes, although you're now operating outside the Bot Framework world.
Bots are just web services. If you unhook security and talk directly to the bot's activity endpoint, you can operate your bot locally on your machine. It may be simpler to just open your own API on the bot's service because emulating what we do in the channels is actually a fair amount of work. (It's by no means impossible -- this is exactly what we do in the emulator -- but there is a fair amount of complexity there.)
If you want to stay within the Bot Framework universe, the bot's endpoint does need to be accessible by the Bot Framework services, i.e. on the internet. If you're publishing on the internet, you will probably want to secure your endpoint, and the Bot Framework security model by design does not allow just anyone to call a bot -- our libraries only allow in authentic Bot Framework services.
Direct Line is intended to power this and we're working on a new version that will preserve the message as it passes through the channel.
If you are improving the direct line API, can I request there is a property in the json response which can be populated with custom metadata?
I have needed to pass specific info to my mobile app and the only way to do this I've found is to send serialised json instead of plain text responses (which looks terrible in all the other channels)
Thanks a lot Dan! If I were to open my own api as you mentioned, would it be possible to just pass message objects to a rest endpoint? What I'm having hard time understanding is how I could use for example Postman to communicate with the bot.
Hi @brendanarnold, yes, your client/bot controls the entire channelData field. Its contents are passed through Direct Line untouched. It's your own private tunnel.
Hi @erlendw, you can certainly reuse any of our libraries to create a custom API if you'd like. It's your API, so you can pass whatever objects you'd like -- if you want to pass objects that look like Bot Framework objects, please feel free :)
@dandriscoll appreciate that you took the time to help! I will try it out!
you can use local tunnels to test your bot locally :)
@rahul251993 I am not familiar with tunnels, would you care to elabourate? :)
@erlendw local tunnels basically provide a URL which you can use to connect with your bot and test locally on slack or whatever application you want. You can do 'npm install -g localtunnel' to install it. Once installed you can setup your application where you want to test your bot either skype or slack or whatever. You also need to change message endpoint of app as : http://test.localtunnel.me/------------ the bot ID. After setup you can run localtunnel in console by using 'lt --port ****--subdomain test'. I hope it helps you. Cheers
@rahul251993 Sweet, this is very helpful because i need to reach some apis that are only available at my office domain, and this means i can test it without deploying to a local server. However I fail to see how it will help with the direct line client stuff tho. But very nice either way :)
Can't get it to work on windows, but it was worth a shot :)
Hi, I am new to microsoft bot framework. Can anyone tell me what is Messaging endpoint URL?
"Messaging endpoint" .... This is your node js sever url which listens to your Bot
Should be something like below https://*********/api/messages
Thanks @VishalWaman. It worked for me.
I saved my bot and tried to test it, following error appears:
500 InternalServerError
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:3978
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Intercom.DevPortal.Server.Controllers.BotManagerController.
Hi @erlendw Can you tell me how to connect bot without using DirectLine API?
Do i need to pass Activity object to connect to chat bot?
I actually never found a solution for this:(
On 17 Feb 2560 BE, at 10:32, Jaya kumar G notifications@github.com wrote:
Hi @erlendw Can you tell me how to connect bot without using DirectLine API?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
I am possibly looking into other solution of chatbot, which are faster and better than directline. :(
Infact i loved the bot framework, but speed matters more than it.
Hi I am working on Microsoft bor framework. Any one tell me, How to work message end point remotely on bot framework emulator..
Hi @erlendw were you able to achieve this? I am trying to do something similar and no luck yet :(
I believe this can be used here: https://www.npmjs.com/package/offline-directline
Why is this issue clossed? Does annyone found a solution for this issue yet?
This issue is closed because the Bot Framework team prefers How To questions be asked on Stack Overflow. GitHub issues is for Feature Requests and Bug reports.
This Load Testing blog post describes how to retrieve a token and call then bot directly: https://blog.botframework.com/2017/06/19/load-testing-a-bot/ (note: you will need to setup a Mock Channel, for the response message.)
@erlendw I guess you are looking into some sort of this https://stackoverflow.com/questions/56573792/using-botframework-emulator-or-bots-hosted-remotely-without-internet-connectivit along the line?
And if not; Is there any way to test direct line locally?