Skip to content

Instantly share code, notes, and snippets.

@stripethree
Last active February 28, 2017 22:02
Show Gist options
  • Save stripethree/a9cdf59b677e167854f4612e4ffa6bb5 to your computer and use it in GitHub Desktop.
Save stripethree/a9cdf59b677e167854f4612e4ffa6bb5 to your computer and use it in GitHub Desktop.
const debug = require('debug')('hello-world:app');
const { Messenger, responses } = require('launch-vehicle-fbm');
const messenger = new Messenger();
messenger.start();
// EVENT HANDLERS
/////////////////
messenger.on('text.greeting', ({senderId, session, firstName, surName, fullName}) => {
const greeting = new responses.Text(`🤖 beep bop boop. Hello ${fullName}, I am a bot.`);
return messenger.send(senderId, greeting);
});
messenger.on('text.help', ({senderId}) => {
const help = new responses.Text(`🤖 I am here to offer my services to assist you.`)
return messenger.send(senderId, help);
});
messenger.on('text', ({senderId, text, source}) => {
const echo = new responses.Text(`Echo echo: "${text}"`);
return messenger.send(senderId, echo);
});
messenger.on('message.text', ({senderId, text, source}) => {
debug(`message.text event processed: ${text}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment