node-messenger-platform

0.0.4 • Public • Published

Facebook Messenger Platform

Node Facebook Messanger Platform adapter built with promises.
Write your best chat bot using best async techology!

Installation

npm install -S node-messenger-platform

Usage

There are two types of usage this node module:

  const FBPlatform = require('node-messanger-platform')
  
  // stateless usage
  FBPlatform.send(token, {id: '123'}, {text: 'hello'})
  FBPlatform.sendImage(token, recipient, message, notificationType)
  
  // or statefull usage
  const Bot = FBPlatform.Bot(token)
  Bot.send(recipient, message, notificationType)

API Reference

Bot

Statefull class for fb messanger platform usage. Stores token in object.

new Bot(token)

Creates an instance of FBPlatform bot using token.

.send(token, recipient, message, [notificationType])

Sending message using token to recipient.

Returns: Promise
See: https://developers.facebook.com/docs/messenger-platform/send-api-reference#request

Param Type Description
token String Facebook Messanger Platform token.
recipient Object Recipient object with id or phone_number fields
message Object Any message object from documentation. message is required property
[notificationType] String Notification type. Default REGULAR

.sendImage(token, recipient, url, [notificationType])

Sending images using token to recipient.

Returns: Promise
See: https://developers.facebook.com/docs/messenger-platform/send-api-reference#request

Param Type Description
token String Facebook Messanger Platform token.
recipient Object Recipient object with id or phone_number fields
url String Image url that you want to send.
[notificationType] String Notification type. Default REGULAR

Package Sidebar

Install

npm i node-messenger-platform

Weekly Downloads

0

Version

0.0.4

License

MIT

Last publish

Collaborators

  • shmuga