Giter VIP home page Giter VIP logo

botmaster-messenger's Introduction

Botmaster-messenger

Build Status Coverage Status npm-version license

This is the FB messenger integration for botmaster. It allows you to use your botmaster bot on FB Messenger

Botmaster is a lightweight chatbot framework. Its purpose is to integrate your existing chatbot into a variety of messaging channels - currently Facebook Messenger, Twitter DM and Telegram.

Documentation

Find the whole documentation for the Botmaster framework on: http://botmasterai.com/documentation/latest

Installing

yarn add botmaster-messenger

or

npm install --save botmaster-messenger

Getting your Credentials

If you don't already have these, follow the steps 1-4 on the Facebook Messenger guide: https://developers.facebook.com/docs/messenger-platform/guides/quick-start

In step 2, where you setup your webhook, no need to code anything. Just specify the webhook, enter any secure string you want as a verify token(verifyToken) and copy that value in the settings object. Also, click on whichever message [those are "update"s using botmaster semantics] type you want to receive from Messenger (message_deliveries, messages, message_postbacks etc...).

To find your Facebook App Secret (fbAppSecret), navigate to your apps dashboard and under App Secret click show, enter your password if prompted and then there it is.

Code

const Botmaster = require('botmaster');
const MessengerBot = require('botmaster-messenger');
const botmaster = new Botmaster();

const messengerSettings = {
  credentials: {
    verifyToken: 'YOUR verifyToken',
    pageToken: 'YOUR pageToken',
    fbAppSecret: 'YOUR fbAppSecret',
  },
  webhookEndpoint: 'webhook1234',
};

const messengerBot = new MessengerBot(messengerSettings);

botmaster.addBot(messengerBot);

botmaster.use({
  type: 'incoming',
  name: 'my-middleware',
  controller: (bot, update) => {
    return bot.reply(update, 'Hello world!');
  }
});

Webhooks

If you are not too sure how webhooks work and/or how to get them to run locally, go to webhooks to read some more.

API

MessengerBot

Extends BaseBot

The class to use if you want to add support for FB Messenger in your Botmaster project.

constructor

Constructor to the MessengerBot class

Parameters

  • settings object MessengerBot take a settings object as first param.

Examples

const messengerBot = new MessengerBot({ // e.g. MessengerBot
  credentials:   credentials: {
    verifyToken: 'YOUR verifyToken',
    pageToken: 'YOUR pageToken',
    fbAppSecret: 'YOUR fbAppSecret',
  },
  webhookEnpoint: 'someEndpoint'
})

_setGetStartedButton

Adds get start button to your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/get-started-button

Parameters

  • getStartedButtonPayload string The payload of the postback you will get when a user clicks on the get started button.
  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_getGetStartedButton

gets get started button payload from your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/get-started-button

Parameters

  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_removeGetStartedButton

removes get started button from your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/get-started-button

Parameters

  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_setPersistentMenu

Adds account Linking to your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/persistent-menu

Parameters

  • persistentMenu string persistent menu to use for your messenger bot
  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_getPersistentMenu

get persistent menu from your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/persistent-menu

Parameters

  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_removePersistentMenu

removes persistent menu from your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/persistent-menu

Parameters

  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_setGreetingText

Adds greeting text to your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text

Parameters

  • greetingObject string greeting objects. Can be localized.
  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_getGreetingText

get greeting text from your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text

Parameters

  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_removeGreetingText

removes greeting text from bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text

Parameters

  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_setWhitelistedDomains

Adds white listed domains to your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/domain-whitelisting

Parameters

  • domainNameLists string List of domains to whitelist.
  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_getWhitelistedDomains

get whitelisted domains from your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text

Parameters

  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_removeWhitelistedDomains

removes whitelisted domains from bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text

Parameters

  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false
  • domainNameLists

_setAccountLinkingUrl

Adds account Linking url to your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/account-linking-url

Parameters

  • accountLinkingURL string Authentication callback URL. Must use https protocol.
  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_getAccountLinkingUrl

get account linking url from your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/account-linking-url

Parameters

  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_removeAccountLinkingUrl

removes account Linking to your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/account-linking-url

Parameters

  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_setTargetAudience

Adds target audience url to your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/target-audience

Parameters

  • targetAudience string
  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_getTargetAudience

get target audience url from your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/target-audience

Parameters

  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

_removeTargetAudience

removes target audience to your bot. Read more here: https://developers.facebook.com/docs/messenger-platform/messenger-profile/target-audience

Parameters

  • resolveWithFullResponse boolean? specify wether request should resolve with full response or not. By default, this is false

License

This library is licensed under the MIT license

botmaster-messenger's People

Contributors

jdwuarin avatar

Watchers

Fabiano Leite avatar James Cloos avatar Rafael Bueno avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.