0.0.4 • Published 8 years ago

node-messenger-platform v0.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

#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

ParamTypeDescription
tokenStringFacebook Messanger Platform token.
recipientObjectRecipient object with id or phone_number fields
messageObjectAny message object from documentation. message is required property
notificationTypeStringNotification 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

ParamTypeDescription
tokenStringFacebook Messanger Platform token.
recipientObjectRecipient object with id or phone_number fields
urlStringImage url that you want to send.
notificationTypeStringNotification type. Default REGULAR