npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

botbuilder-facebook

v1.0.7

Published

Facebook Bot connector for MS BotBuilder

Downloads

12

Readme

botbuilder-facebook

Facebook Messenger bot connector for Microsoft BotBuilder.

Get started

  1. Install botbuilder-facebook
npm install botbuilder-facebook --save
  1. Initialize Facebook Bot.

bot.js:

'use strict'

const FacebookBot = require('botbuilder-facebook');

const bot = new FacebookBot({
  pageToken: 'YOUR_FB_PAGE_TOKEN',
  validationToken: 'APP_VERIFICATION_TOKEN'
});

bot.add('/', session => {
  session.send('Hello!');
});
  1. Run express server and listen to messages
'use strict';

const server     = require('express')();
const bodyParser = require('body-parser');

const bot = require('./bot');

server.use(bodyParser.json());

server.get('/', (req, res) => {
  bot.botService.validate(req.query, function(err, challenge) {
    if (err) {
      console.error(err);
      res.send('Error, validation failed');
      return;
    }
    console.log('validation successful');
    res.send(200, challenge);
  });
});

server.post('/', (req, res) => {
  bot.botService.receive(req.body);
  res.sendStatus(200);
});

server.listen(5000, function() {
  console.log(`Bot server listening on port 5000`);
});

Message examples

All examples is done using builder.Message object, but you can use a plain JS object as well. Something like this:

session.send({
  attachments: [{
    thumbnailUrl: "http://petersapparel.parseapp.com/img/item101-thumb.png",
    title: "Classic Grey T-Shirt",
    titleLink: "https://petersapparel.parseapp.com/view_item?item_id=101",
    text: "Soft white cotton t-shirt is back in style"
  }]
});
  1. Message with image attachment
  var msg = new builder.Message()
    .addAttachment({
      contentUrl: "http://www.theoldrobots.com/images62/Bender-18.JPG",
      contentType: "image/jpeg"
    });
  return session.send(msg);
  1. Generic template
var msg = new builder.Message()
  .addAttachment({
      thumbnailUrl: "http://petersapparel.parseapp.com/img/item101-thumb.png",
      title: "Classic Grey T-Shirt",
      titleLink: "https://petersapparel.parseapp.com/view_item?item_id=101",
      text: "Soft white cotton t-shirt is back in style"
  });
  1. Generic template with Call-To-Action items and bubbles
var msg = new builder.Message();
msg.addAttachment({
    title: "Classic White T-Shirt",
    text: "Soft white cotton t-shirt is back in style",
    thumbnailUrl: "http://petersapparel.parseapp.com/img/item100-thumb.png",
    actions: [
        { title: "View Item", url: "https://petersapparel.parseapp.com/view_item?item_id=100" },
        { title: "Buy Item", message: "buy:100" },
        { title: "Bookmark Item", message: "bookmark:100" }
    ]
});
msg.addAttachment({
    title: "Classic Grey T-Shirt",
    text: "Soft gray cotton t-shirt is back in style",
    thumbnailUrl: "http://petersapparel.parseapp.com/img/item101-thumb.png",
    actions: [
        { title: "View Item", url: "https://petersapparel.parseapp.com/view_item?item_id=101" },
        { title: "Buy Item", message: "buy:101" },
        { title: "Bookmark Item", message: "bookmark:101" }
    ]
});
  1. Receipt or any other custom message template
var msg = new builder.Message();
msg.setChannelData({
    "attachment":{
        "type":"template",
        "payload":{
            "template_type":"receipt",
            "recipient_name":"Stephane Crozatier",
            "order_number":"12345678902",
            "currency":"USD",
            "payment_method":"Visa 2345",
            "order_url":"http://petersapparel.parseapp.com/order?order_id=123456",
            "timestamp":"1428444852",
            "elements":[
                {
                    "title":"Classic White T-Shirt",
                    "subtitle":"100% Soft and Luxurious Cotton",
                    "quantity":2,
                    "price":50,
                    "currency":"USD",
                    "image_url":"http://petersapparel.parseapp.com/img/whiteshirt.png"
                },
                {
                    "title":"Classic Gray T-Shirt",
                    "subtitle":"100% Soft and Luxurious Cotton",
                    "quantity":1,
                    "price":25,
                    "currency":"USD",
                    "image_url":"http://petersapparel.parseapp.com/img/grayshirt.png"
                }
            ],
            "address":{
                "street_1":"1 Hacker Way",
                "street_2":"",
                "city":"Menlo Park",
                "postal_code":"94025",
                "state":"CA",
                "country":"US"
            },
            "summary":{
                "subtotal":75.00,
                "shipping_cost":4.95,
                "total_tax":6.19,
                "total_cost":56.14
            },
            "adjustments":[
                {
                    "name":"New Customer Discount",
                    "amount":20
                },
                {
                    "name":"$10 Off Coupon",
                    "amount":10
                }
            ]
        }
    }
});

License

MIT License

  • http://www.opensource.org/licenses/mit-license.php