express-facebook-messenger

Tiny Facebook Messenger Bot utilty

Usage no npm install needed!

<script type="module">
  import expressFacebookMessenger from 'https://cdn.skypack.dev/express-facebook-messenger';
</script>

README

Install

npm install express-facebook-messenger

Getting started

1. Setup a Facebook App and Page and note down the generated page token.

2. Build bot

var express = require('express');
var bodyParser = require('body-parser');
var bot = require('../lib/')('<token>');

// or

var bot = require('../lib/')({
  validationToken: '<token>',
  pageAccessToken: '<token>'
});


var app = express();

bot.on('message', function(senderId, msg){
  this.send(senderId, {
    text: 'Hello to you too!'
  });
});

app.use(bodyParser.json());

app.use('/hook', bot.router());

app.listen(5000);

Example

To run the example app:

  • Install ngrok
  • Start ngrok tunnel
ngrok http 5000
  • Note the generated url and use it to add a webhook to your FB app.
  • Run
TOKEN='<your page token>' node test/simple.js

Contribute

Lmk ...