
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
facebook-messenjs
Advanced tools
Facebook MessenJS is an API wrapper for Facebook Messenger inspired by discord.js. This library allows you to interact with Facebook Messenger's API. The bot was programmed with an object-oriented approach so that people can program their Facebook Messenger chatbots with ease.
npm i facebook-messenjs
Create a simple quick example bot:
const { Client } = require('facebook-messenjs');
const bot = new Client({
pageToken: "PAGE_TOKEN_FROM_FACEBOOK",
verifyToken: "YOUR_VERIFY_TOKEN",
appID: "APP_ID_FROM_FACEBOOK"
});
// Allows Facebook to know that you set the URL of the bot properly
bot.on('webhookVerify', verification => {
if (verification.success) {
console.log("Webhook verified with Facebook successfully!");
} else {
console.log("Webhook verified with Facebook failed! ;-;");
}
});
// Processes messages from people who message the Facebook page
bot.on("messages", message => {
message.sender.send("Hi!");
});
// Turns on the bot at port 5566
bot.listen(5566, () => {
console.log(`Facebook Messenger chatbot listening at http://localhost:${bot.port}`);
});
Create text quick replies:
const { Client, TextQuickReply } = require('facebook-messenjs');
bot.on('messages', message => {
if (!message.payload) { // Checks if the message has a payload
message.sender.send("Hi! What is your favorite color?", [
new QuickReplies.Text("Red", "RESPONSE_RED"),
new QuickReplies.Text("Yellow", "RESPONSE_YELLOW"),
new QuickReplies.Text("Others", "RESPONSE_OTHERS")
]);
} else {
// Responds appropriately to payloads
switch (message.payload) {
case "RESPONSE_RED":
message.sender.send("Red? Me too!");
break;
case "RESPONSE_OTHERS":
message.sender.send("Yellow? That's a nice color!");
break;
default:
message.sender.send("I like that color too.");
}
}
});
Set persistent menu:
const { Client, PostbackButton } = require('facebook-messenjs');
bot.on('messagingPostback', postback => {
if (postback.payload === "GET_STARTED") {
postback.sender.setPersistentMenu([
new PostbackButton("Button 1", "PAYLOAD_ONE"),
new PostbackButton("Button 2", "PAYLOAD_TWO")
]);
}
});
Send pictures:
const { Client, BaseAttachment } = require('facebook-messenjs');
const picture = new BaseAttachment(bot, "image", {
content: "./picture.png",
reusable: true
});
bot.on("messages", message => {
message.sender.send(picture);
});
FAQs
API wrapper for Facebook Messenger inspired by discord.js
We found that facebook-messenjs 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
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.