fbmessenger-node-bot
v1.0.7
Published
Module for creating FB Messenger bots.
Downloads
10
Maintainers
Readme
fbmessenger-node-bot
Arhitecture based on https://github.com/Naltox/telegram-node-bot
Very powerful module for creating Facebook Messenger bots.
Get started
Now let's write simple bot!
'use strict'
const FBMB = require('fbmessenger-node-bot'),
FBMessenger = FBMB.FBMessenger,
FBMessengerBaseController = FBMB.FBMessengerBaseController,
TextCommand = FBMB.TextCommand
let fb = new FBMessenger(config.get('fb.PAGE_ACCESS_TOKEN'), {
webhook: config.get('fb.webhook'),
validation_token: config.get('fb.VALIDATION_TOKEN')
})
class PingController extends FBMessengerBaseController {
/**
* @param {Scope} $
*/
pingHandler($) {
$.api.sendTextMessage('pong')
}
get routes() {
return {
'pingCommand': 'pingHandler'
}
}
}
fb.router
.when(
new TextCommand('ping', 'pingCommand'),
new PingController()
)