
Security News
Node.js Homepage Adds Paid Support Link, Prompting Contributor Pushback
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
messenger-flow
Advanced tools
A modern, easy-to-use Facebook Messenger bot framework for Node.js. Features built-in webhook, conversation flows, keyword and event handling, and user profile support.
A modern, easy-to-use Facebook Messenger bot framework for Node.js. Features built-in webhook, conversation flows, keyword and event handling, and user profile support.
.hear
.on
(e.g., message, postback)Install from your local path (or from npm if published):
npm install messenger-flow
const MessengerFlow = require('messenger-flow');
const bot = new MessengerFlow({
accessToken: 'YOUR_PAGE_ACCESS_TOKEN',
verifyToken: 'YOUR_VERIFY_TOKEN',
appSecret: 'YOUR_APP_SECRET', // optional, for advanced use
webhook: '/webhook' // optional, default is '/webhook'
});
bot.start(3000); // Start server on port 3000
bot.hear(['hi', 'hello', /hey/i], (event, chat) => {
chat.say('Hello! How can I help you?');
});
bot.on('message', (event, chat, { captured }) => {
if (!captured) chat.say('I did not understand that.');
});
bot.on('postback', (event, chat) => {
chat.say('You clicked a button!');
});
bot.hear('survey', (event, chat) => {
chat.conversation(convo => {
convo.ask('What is your name?', async (event, convo) => {
convo.set('name', event.message.text);
await convo.say(`Nice to meet you, ${convo.get('name')}!`);
convo.ask('How old are you?', async (event, convo) => {
convo.set('age', event.message.text);
await convo.say(`You are ${convo.get('age')} years old.`);
convo.end();
});
});
});
});
bot.say(USER_ID, 'Hello!');
bot.say(USER_ID, {
text: 'Choose an option:',
quick_replies: [
{ content_type: 'text', title: 'Option 1', payload: 'OPTION_1' },
{ content_type: 'text', title: 'Option 2', payload: 'OPTION_2' }
]
});
// Or with options:
bot.say(USER_ID, 'Pick one:', {
quickReplies: [
{ content_type: 'text', title: 'Yes', payload: 'YES' },
{ content_type: 'text', title: 'No', payload: 'NO' }
]
});
bot.getUserProfile(USER_ID).then(profile => {
console.log(profile);
});
accessToken
(string, required): Facebook Page Access TokenverifyToken
(string, required): Token for webhook verificationappSecret
(string, optional): Facebook App Secretwebhook
(string, optional): Webhook endpoint path (default: /webhook
)start(port)
: Start the Express serverhear(keywords, callback)
: Listen for keywords/regex in messageson(event, callback)
: Listen for Messenger events (e.g., 'message', 'postback')say(userId, message, opts)
: Send a message to a usergetUserProfile(userId)
: Fetch user profile infoconversation(userId, factory)
: Start a conversation with a userask(question, answer)
: Ask a question and handle the answersay(message)
: Send a message in the conversationset(key, value)
: Store data in conversation contextget(key)
: Retrieve data from contextend()
: End the conversationconst MessengerFlow = require('messenger-flow');
const bot = new MessengerFlow({
accessToken: 'PAGE_TOKEN',
verifyToken: 'VERIFY_TOKEN',
});
bot.hear('hi', (event, chat) => chat.say('Hello!'));
bot.on('message', (event, chat, { captured }) => {
if (!captured) chat.say('Type "hi" to start!');
});
bot.start(3000);
MIT
FAQs
A modern, easy-to-use Facebook Messenger bot framework for Node.js. Features built-in webhook, conversation flows, keyword and event handling, and user profile support.
The npm package messenger-flow receives a total of 13 weekly downloads. As such, messenger-flow popularity was classified as not popular.
We found that messenger-flow demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.
Research
Security News
The Socket Research Team investigates a malicious Python typosquat of a popular password library that forces Windows shutdowns when input is incorrect.