Skip to content

Module to receive sample messages of all types from a Facebook Messenger chatbot

License

Notifications You must be signed in to change notification settings

smalltalk-ai/botkit-messenger-samples

Repository files navigation

botkit-messenger-samples

npm

Module to receive sample messages of most types from a Facebook Messenger chatbot.

Takes the idea of sample message types from the Facebook Messenger Platform Sample project and moves it into a module for Botkit.

For usage sample code see examples/sample_bot.js

Steps for using lib

Install library from npm

npm install --save botkit-messenger-samples

Import Library

const MessengerSamples = require('botkit-messenger-samples');

Init the Library

controller.setupWebserver(process.env.port,function(err, webserver) {
  var messengerSamples = new MessengerSamples(controller, bot, {
    // serverUrl (e.g., https://my.domain.com)
    // needed to server up sample images
    serverUrl: process.env.serverUrl
    //, replyCb = function(err, body) {
    //    // call after a sample message is sent
    //  }
  });
});

Available Commands in Messenger

Command Results
sample:help text list of available commands
sample:audio an Audio Attachment embedded in a player
sample:button a Button Template
sample:file a text File Attachment
sample:generic a Generic Template
sample:gif an animated GIF Image Attachment
sample:image an Image Attachment
sample:image:tall a very tall Image Attachment
sample:image:wide a very wide Image Attachment
sample:list a List Template top_element_style:large
note: on web, it is rendered as compact
sample:list:compact a List Template top_element_style:compact
sample:quick reply a text message with Quick Replies
sample:read receipt the mark_seen Sender Action
sample:receipt a Receipt Template
sample:typing on the typing_on Sender Action
sample:typing off the typing_off Sender Action
sample:video a Video Attachment embedded in a player
sample:json:{
"text": "Lorem Ipsum!"
}
any message type; after the sample:json: add any valid message, see Send API Reference

JSON Examples

Simple text

sample:json:{
  "text": "hello world"
}

Muliple messages

sample:json:[{
  "text": "hello world"
},{
  "attachment": {
    "type": "template",
    "payload": {
      "template_type": "generic",
      "elements": [
        {
          "title": "rift",
          "subtitle": "Next-generation virtual reality",
          "item_url": "https://www.oculus.com/en-us/rift/",
          "image_url": "http://assets.smalltalk.ai/sample-message/rift.png",
          "buttons": [
            {
              "type": "web_url",
              "url": "https://www.oculus.com/en-us/rift/",
              "title": "Open Web URL"
            },
            {
              "type": "postback",
              "title": "Call Postback",
              "payload": "Payload for first bubble"
            }
          ]
        },
        {
          "title": "touch",
          "subtitle": "Your Hands, Now in VR",
          "item_url": "https://www.oculus.com/en-us/touch/",
          "image_url": "http://assets.smalltalk.ai/sample-message/touch.png",
          "buttons": [
            {
              "type": "web_url",
              "url": "https://www.oculus.com/en-us/touch/",
              "title": "Open Web URL"
            },
            {
              "type": "postback",
              "title": "Call Postback",
              "payload": "Payload for second bubble"
            }
          ]
        }
      ]
    }
  }
}]

About

Module to receive sample messages of all types from a Facebook Messenger chatbot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published