botmasterai / botmaster

The chatbot framework for your serious projects
http://botmasterai.com/
MIT License
251 stars 47 forks source link

Add multiple instances of Messenger Bot #37

Closed mronceray closed 6 years ago

mronceray commented 6 years ago

Hi 👋, i'm making a project where i have to implement the same bot on multiple pages with a single Facebook app. I tried to create multiple instances of a Messenger bot like this :

const botmaster = new Botmaster();

const MessengerBot = require('botmaster-messenger');

botmaster.addBot(new MessengerBot({
  credentials: {
    verifyToken: 'TOKEN',
    pageToken: '[myPageToken1]',
    fbAppSecret: '[myAppSecret]',
  },
  webhookEndpoint: 'webhook'
}));

botmaster.addBot(new MessengerBot({
  credentials: {
    verifyToken: 'TOKEN',
    pageToken: '[myPageToken2]',
    fbAppSecret: '[myAppSecret]',
  },
  webhookEndpoint: 'webhook'
}));

botmaster.addBot(new MessengerBot({
  credentials: {
    verifyToken: 'TOKEN',
    pageToken: '[myPageToken3]',
    fbAppSecret: '[myAppSecret]',
  },
  webhookEndpoint: 'webhook'
}));

It works for one of my pages only, but when i chat by the other connected pages i've this error in the my console :

(node:62803) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Uncaught, unspecified "error" event. ([object Object])

If anyone understands this error and knows how to solve this problem, I would like to have some clarification. Thank you for your reply

jdwuarin commented 6 years ago

Hi - this issue should be in botmaster-messenger and would be a duplicate there: https://github.com/botmasterai/botmaster-messenger/issues/5 There is a pull request for it that has been abandoned: https://github.com/botmasterai/botmaster-messenger/pull/7 And I've commited to add support for this over the weekend. Closing this and letting you go to the mentioned botmaster-messenger issues

jdwuarin commented 6 years ago

This was fixed here: https://github.com/botmasterai/botmaster-messenger/commit/477650a77d18a5bf104562bdb66b734f57bd97e3