Facebook MessenJS
Facebook MessenJS is an API wrapper for Facebook Messenger inspired by discord.js that 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.
Installation
npm i facebook-messenjs
Simple Chatbot
const { Client } = require('facebook-messenjs');
const bot = new Client({
pageToken: "PAGE_TOKEN_FROM_FACEBOOK",
verifyToken: "YOUR_VERIFY_TOKEN",
appID: "APP_ID_FROM_FACEBOOK"
});
bot.on('webhookVerify', verification => {
if (verification.success) {
console.log("Webhook verified with Facebook successfully!");
} else {
console.log("Webhook verified with Facebook failed! ;-;");
}
});
bot.on("messages", message => {
message.sender.send("Hi!");
});
bot.listen(5566, () => {
console.log(`Facebook Messenger chatbot listening at http://localhost:${bot.port}`);
})