I have a botkit bot that’s been working well in production for about 6 months (code here, live bot here). It uses Dialogflow and Facebook Messenger. Now I want to add webchat too. Can botkit do multi-platform in one app?
I could have two different apps running, but there's a bunch of logic I've written to deal with Dialogflow's responses, and to talk to my db, that would feel ugly to duplicate.
@benbrown any thoughts on this?
You can bind the same handlers to a different controller in the same app, yes. However you will likely need to adjust some platform specific things.
Would you do that by passing an array of adapters to the controller?
On Wed, 3 Jul 2019, 3:18 AM Ben Brown, notifications@github.com wrote:
You can bind the same handlers to a different controller in the same app,
yes. However you will likely need to adjust some platform specific things.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/howdyai/botkit/issues/1697?email_source=notifications&email_token=AAKRE76ZA6P5KG4WTQUVBO3P5NWUNA5CNFSM4H2YKIZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZBT3XI#issuecomment-507723229,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAKRE74UZ5PZHEZ4ZHHFG23P5NWUNANCNFSM4H2YKIZA
.
Oh sorry I missed the note about using 4.x.
No, what you'd do is set up a second webhook endpoint for the new adapter, and pass in the main Botkit turnhandler function -- something like the code here:
https://github.com/howdyai/botkit/blob/master/packages/botkit/src/core.ts#L677
Thanks @benbrown. Sounds a bit beyond my skills.
Is there a place where we can get a good documentation about different terms such context, processActivity ... to properly understand what they are cause it is the key to any customization one would like to bring in.
The code would be something just like this:
const secondadapter = new SomeOtherAdapter();
controller.webserver.post('/YOUR-CUSTOM-ENDPOINT, (req, res) => {
// Allow the Botbuilder middleware to fire.
// this middleware is responsible for turning the incoming payload into a BotBuilder Activity
// which we can then use to turn into a BotkitMessage
secondadapter.processActivity(req, res, controller.handleTurn.bind(controller)).catch((err) => {
console.error('Experienced an error inside the turn handler', err);
throw err;
});
});
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
The code would be something just like this: