Closed mronceray closed 6 years ago
Can you post all the code you are running so I see where the error could come from?
Also, the Readme was a bit off. Thanks for pointing that out. Updating it now
const Botmaster = require('botmaster');
const MessengerBot = require('botmaster-messenger');
const botmaster = new Botmaster();
const messengerSettings = {
credentials: {
verifyToken: 'TOKEN',
fbAppSecret: 'fdbd2ec***',
pages: {
'1572***': {
pageToken: 'EAAN***'
},
'10227***': {
pageToken: 'EAAN***'
},
'177399***': {
pageToken: 'EAAN***'
}
}
},
webhookEndpoint: 'webhook',
};
const messengerBot = new MessengerBot(messengerSettings);
botmaster.addBot(messengerBot);
botmaster.use({
type: 'incoming',
name: 'my-middleware',
controller: (bot, update) => {
const messageToSend = bot.createOutgoingMessageFor(userId);
messageToSend.addText('Hello World');
messageToSend.sender = {
id: '1773***',
};
return bot.sendMessage(messageToSend);
}
});
Right. Another issue with the Readme; Your middleware should read:
botmaster.use({
type: 'incoming',
name: 'my-middleware',
controller: (bot, update) => {
const messageToSend = bot.createOutgoingMessageFor(update.sender.id); // or another userId you know about
messageToSend.addText('Hello World');
messageToSend.sender = {
id: '1773***',
};
return bot.sendMessage(messageToSend);
}
});
Perfect, it works! Thank you
Just to let you know that I just deployed a new version that will let you use multi-pages like before. I.e. no need to specify the pageId (only works within middleware) - as the pageId defaults to whichever page received an update. This means, all the reply, send* functions will now work also for multi-page bots. Checkout the updated docs.
Hi 👋 I want to thank @jdwuarin who worked on on the support of several Facebook pages. I did some tests using two pages.
I had this error at first
The error was no longer displayed by placing "fbAppSecret" above "pages" like that
But I still have an error that I do not understand how to debug it
I have this error in my terminal when I send a message to my facebook page
(node:73321) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: Uncaught, unspecified "error" event. ([object Object])
I'm not sure if I'm using the example correctly, do you know where the error comes from?
Thank you for your reply