Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
chatbottle-api-nodejs
Advanced tools
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:
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 = require('./chatbottle')(process.env.CHATBOTTLE_API_TOKEN_MESSENGER, { platform: 'messenger' });
const chatbottleLine = require('./chatbottle')(process.env.CHATBOTTLE_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 = require('./chatbottle')(process.env.CHATBOTTLE_API_TOKEN_MESSENGER, { platform: 'messenger', debug: true, debugRequest: true });
Then log whenever your webhook is called.
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.post(webHookPath, function (req, res) {
chatbottleMessenger.log(req.body);
const messagingEvents = req.body.entry[0].messaging;
if (messagingEvents.length && messagingEvents[0].message && messagingEvents[0].message.text) {
const event = req.body.entry[0].messaging[0];
const sender = event.sender.id;
const text = event.message.text;
const requestData = {
url: 'https://graph.facebook.com/v2.6/me/messages',
qs: { access_token: process.env.FACEBOOK_PAGE_TOKEN },
method: 'POST',
json: {
recipient: { id: sender },
message: {
text: 'ECHO: ' + text
}
}
};
request(requestData);
}
res.sendStatus(200);
});
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.log({
id: event.message ? event.message.id : event.timestamp,
text: event.message.text,
userId: event.source.userId,
direction: 'In',
});
// outgoing
// you can listen on every outgoing request with monkey-patching (see below) ;)
chatbottleLine.log({
id: new Date().getTime(),
text: message, // if you have rich content, you can build your message on your own and JSON.stringify() it
userId: to,
direction: 'Out',
});
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/
FAQs
ChatBottle API client for Node.js
We found that chatbottle-api-nodejs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.