Neutered Puppy Masquerade
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    facebook-messenger-streamspublic

    Facebook Messenger Streams

    Wrap Facebook Messenger API in a stream-oriented interface. Using streams allows using a piping/filtering metaphor on incoming/outgoing messages which may help structure code better.

    Usage

    var FBInputStream = require('facebook-messenger-streams').InputStream;
    var FBUserOutputStream = require('facebook-messenger-streams').UserOutputStream;
     
    var fbInputStream = new FBInputStream(
        'mysecrettoken',
        process.env.APP_SECRET
    );
     
    fbInputStream.on('data', function (data) {
        var senderId = data.sender.id;
     
        console.log('got data from user', senderId, data);
     
        var userOutputStream = new FBUserOutputStream(
            process.env.PAGE_TOKEN,
            senderId
        );
     
        userOutputStream.write({ text: 'Hi there!' });
    });
     
    var app = new express.Router();
    app.listen(process.env.PORT || 3000);
     
    app.use('/webhook', fbInputStream.webhookRouter);

    Keywords

    none

    install

    npm i facebook-messenger-streams

    Downloadslast 7 days

    2

    version

    0.0.2

    license

    ISC

    repository

    github.com

    last publish

    collaborators

    • avatar