Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Create a websocket server enabled Botkit connector which can manage multiple remote clients #871

Closed
benbrown opened this issue Jun 6, 2017 · 9 comments

Comments

@benbrown
Copy link
Contributor

benbrown commented Jun 6, 2017

This represents an important next step on the roadmap for Botkit: a native communication channel that allows Botkit to talk directly to the web, native clients, or custom platforms.

This is ACTIVELY UNDER DEV and slated for release for a few weeks from now!

Amongst the many todos:

  • Add documentation for using the websocket
  • Expand the client code and make it friendlier to use with tools like React and Angular
  • Publish a mechanism for expanding the message object schema (or adopting other formats)
  • Make the socket server more robust
@benbrown
Copy link
Contributor Author

benbrown commented Jun 6, 2017

The code for this is available in this pull request:
#872

I've also created a simple web client starter kit, which will pull the Botkit dev/webchannel branch by default until this is merged into master:
https://github.com/howdyai/botkit-starter-web

@mien
Copy link

mien commented Jun 8, 2017

can we use this library https://github.com/primus/primus to let the user use any socket library he wishes to.

@benbrown
Copy link
Contributor Author

benbrown commented Jun 8, 2017

@MunawwarHussain That is very interesting! I'll have to take a look. What are the alternative socket libraries you are interested in?

@maxmeinberg
Copy link

@benbrown we are waiting for something like this!!!

Is it possible to use the Web Bot without a Botkit Studio token, running in my own server?

@peterswimm
Copy link
Contributor

@maxmeinberg Yes! You can run it standalone like any other integration, but studio will greatly extend it's capabilities.

@mien
Copy link

mien commented Jun 9, 2017

@benbrown no problem as such its good to have an abstraction and make it library independent.

@maxmeinberg
Copy link

@benbrown I'm trying to use this Web Bot with my existing Facebook bot and got this error message
"Cannot read property 'middleware' of undefined" when call Web.controller.middleware.receive.use(middleware.receive);

Is it possible to use the Web Bot in same server with Facebook Bot and Watson?

This is part of my code:
module.exports = function(app) {
if (process.env.USE_WEB) {
var Web = require('./bot-web');
Web.controller.middleware.receive.use(middleware.receive);
console.log('Web bot is live');
}
if (process.env.USE_FACEBOOK) {
var Facebook = require('./bot-facebook');
Facebook.controller.middleware.receive.use(middleware.receive);
Facebook.controller.createWebhookEndpoints(app, Facebook.bot);
console.log('Facebook bot is live');
}

// Customize your Watson Middleware object's before and after callbacks.
middleware.before = function(message, conversationPayload, callback) {
if (message.user == process.env.FACE_PAGE_ID)
callback(null, conversationPayload);
else
callback(true);
}

middleware.after = function(message, conversationResponse, callback) {
console.log('After message', message);
callback(null, conversationResponse);
}
};

Thank you very much!!

@tmundt
Copy link

tmundt commented Jun 17, 2017

@maxmeinberg That should work, as you pass in middleware depending on Node's ENV variable setting! Would be interesting how you handle of different tokens depending on the Bot's realm (that is Facebook, Slack and the like).

@gagan-bansal
Copy link

+1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants