ChatBottle API for Node.js
ChatBottle is an engagement platform for your chatbots. ChatBottle allows to send personalized notifications to segmented groups of users.
The following platforms are currently supported via the npm package:
Setup Bot
Create a free account at https://chatbottle.co/ and get a ChatBottle token.
chatbottle is available via NPM.
npm install --save chatbottle-api-nodejs
Include chatbottle and create instance for each platform (if you have mor than one).
const chatbottleMessenger = processenvCHATBOTTLE_API_TOKEN_MESSENGER platform: 'messenger' ;const chatbottleLine = processenvCHATBOTTLE_API_TOKEN_LINE platform: 'line' ;...
You can enable debugging in the second parameter config
if you have problems.
//@param config object {// platform => messenger, telegram,// debug => see every outgoing data,// debugRequest => to set the request-promise library to debug// }const chatbottleMessenger = processenvCHATBOTTLE_API_TOKEN_MESSENGER platform: 'messenger' debug: true debugRequest: true ;
Then log whenever your webhook is called.
Logging
Messenger
Facebook Messenger is directly supported to send the req.body
directly to chatbottle if you enable the following events for your webhook:
https://developers.facebook.com/docs/messenger-platform/webhook-reference/message-echo https://developers.facebook.com/docs/messenger-platform/webhook-reference/message-delivered https://developers.facebook.com/docs/messenger-platform/webhook-reference/message-received https://developers.facebook.com/docs/messenger-platform/webhook-reference/message-read
app;
Generic (Kik, Viber, Line, ...)
For generic bot platforms you have hook in every receiving and sending message.
// incoming// lets say the incoming message is `event` (for Line Bot)chatbottleLine; // outgoing// you can listen on every outgoing request with monkey-patching (see below) ;)chatbottleLine;
Monkey-patching: Track outgoing HTTP(s) requests in NodeJS by @phips28
https://chatbotsmagazine.com/track-outgoing-http-s-requests-in-nodejs-48608553f03c#.mz675gyuf
That is it!
For a complete example see: facebook-example.js
Register on ChatBottle: https://chatbottle.co/