All Projects → DiegoRBaquero → Node Fb Messenger

DiegoRBaquero / Node Fb Messenger

Licence: mit
✉️ Facebook Messenger Platform Node.js API Wrapper

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Node Fb Messenger

Messenger4j
A Java library for building Chatbots on the Facebook Messenger Platform - easy and fast.
Stars: ✭ 199 (-3.4%)
Mutual labels:  api, bot, messenger, facebook
Pymessager
Python API to develop chatbot on Facebook Messenger Platform
Stars: ✭ 580 (+181.55%)
Mutual labels:  api, bot, messenger, facebook
Swiftybot
How to create a Telegram, Facebook Messenger, and Google Assistant bot with Swift using Vapor on Ubuntu / macOS.
Stars: ✭ 247 (+19.9%)
Mutual labels:  bot, messenger, facebook
Messenger
Package messenger is used for making bots for use with Facebook messenger
Stars: ✭ 278 (+34.95%)
Mutual labels:  api, bot, messenger
Fbrecog
An unofficial python wrapper for the Facebook face recognition endpoint
Stars: ✭ 184 (-10.68%)
Mutual labels:  api, wrapper, facebook
Miscord
Facebook Messenger to Discord bridge
Stars: ✭ 225 (+9.22%)
Mutual labels:  bot, messenger, facebook
Facebook Messenger
Definitely the best way to make Bots on Facebook Messenger with Ruby
Stars: ✭ 927 (+350%)
Mutual labels:  bot, messenger, facebook
Fbmessenger Node
FB messenger for node
Stars: ✭ 52 (-74.76%)
Mutual labels:  bot, messenger, facebook
Bootbot
Facebook Messenger Bot Framework for Node.js
Stars: ✭ 886 (+330.1%)
Mutual labels:  bot, messenger, facebook
Spotify Bot
Spotify Messenger Bot
Stars: ✭ 12 (-94.17%)
Mutual labels:  bot, messenger, facebook
Broid Kit
Bot framework powered by Broid
Stars: ✭ 58 (-71.84%)
Mutual labels:  api, bot, messenger
Magento Chatbot
Magento Chatbot Integration with Telegram, Messenger, Whatsapp, WeChat, Skype and wit.ai.
Stars: ✭ 149 (-27.67%)
Mutual labels:  bot, messenger, facebook
React Messenger
Chat UX components built with React, inspired by Facebook Messenger
Stars: ✭ 167 (-18.93%)
Mutual labels:  messenger, facebook
Spaces Api
An API wrapper for DigitalOcean's Spaces object storage designed for easy use.
Stars: ✭ 166 (-19.42%)
Mutual labels:  api, wrapper
Slack Starterbot
Python-powered simple starter Slack bot.
Stars: ✭ 169 (-17.96%)
Mutual labels:  api, bot
Whatsapp Bot
BOT - WhatsApp Web in TypeScript
Stars: ✭ 170 (-17.48%)
Mutual labels:  api, bot
Jda
Java wrapper for the popular chat & VOIP service: Discord https://discord.com
Stars: ✭ 2,598 (+1161.17%)
Mutual labels:  api, bot
Whatsapp Web.js
A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
Stars: ✭ 4,103 (+1891.75%)
Mutual labels:  api, bot
Csgofloat Inspect
Source Code that Powers the CSGOFloat Inspect Link API
Stars: ✭ 172 (-16.5%)
Mutual labels:  api, bot
Wiki
Wikipedia Interface for Node.js
Stars: ✭ 180 (-12.62%)
Mutual labels:  api, wrapper

fb-messenger npm npm npm

Facebook Messenger Platform NodeJS API Wrapper

js-standard-style Greenkeeper badge Codacy Badge Code Climate

Installation

Requires Node 8+

npm install fb-messenger --save

API

You must require fb-messenger and create an instance

// Constructor
const FBMessenger = require('fb-messenger')
const messenger = new FBMessenger({token, notificationType})
// token is optional, if not included, must be sent in each method, notificationType is optional, default = 'REGULAR'

messenger.setToken(token) // Sets the instance token

messenger.setNotificationType(notificationType) // Sets the instance notificationType

// Methods (notificationType and token are optional)
messenger.sendTextMessage({id, message, notificationType, token}) // Sends a text message

messenger.sendAudioMessage({id, url, notificationType, token}) // Sends an audio from URL

messenger.sendVideoMessage({id, url, notificationType, token}) // Sends an video from URL

messenger.sendImageMessage({id, url, notificationType, token}) // Sends an image from URL

messenger.sendFileMessage({id, url, notificationType, token}) // Sends an file from URL

messenger.sendQuickRepliesMessage({id, attachment, quickReplies, notificationType, token}) // Sends a Quick Replies Message

messenger.sendButtonsMessage({id, message, buttons, notificationType, token}) // Sends a buttons template message

messenger.sendGenericMessage({id, elements, notificationType, token}) // Sends a generic template message

messenger.sendListMessage({id, elements, buttons, top_element_type, notificationType, token}) // Sends a list template message

messenger.sendMediaMessage({id, elements, notificationType, token}) // Sends a media template message

messenger.sendOpenGraphMessage({id, elements, notificationType, token}) // Sends an open graph template message

messenger.sendReceiptMessage({id, payload, notificationType, token}) // Sends a receipt template message (No need for template_type in payload) 

messenger.sendAction({id, actionType, token}) // Send an action type (One of 'mark_seen', 'typing_on', 'typing_off')

messenger.sendMessage({id, data, notificationType, token}) // Send a message from custom data

messenger.getProfile({id, token}) // Gets user information

messenger.setWelcomeMessage({pageId, message, token}) // Sets Page's Welcome Message (message can be a text string or a strucuted message)

messenger.setGreetingText ({pageId, message, token}) // Sets Page's Greeting Text

messenger.setPersistentMenu ({pageId, menuItems, token}) // Set's Page's Persistent Menu

messenger.setDomainWhitelist ({pageId, domains, token}) // Set's Page's Whitelisted Domains 

messenger.sendThreadSettingsMessage ({pageId, body, token}) // Send Manually Page's Thread Settings

Notification Types:

  • REGULAR
  • SILENT_PUSH
  • NO_PUSH

Examples

Basic Example

const FBMessenger = require('fb-messenger')
const messenger = new FBMessenger({token: '<YOUR TOKEN>'}) // Will always use this page's token for request unless sent on each method

messenger.sendTextMessage({id: '<ID>', text: 'Hello'})

Catch errors Example

const FBMessenger = require('fb-messenger')
const messenger = new FBMessenger({token: '<YOUR TOKEN>'})

try {
  const response = await messenger.sendTextMessage({id: '<ID>', text: 'Hello'})
  console.log(response)
} catch (e) {
  console.error(e)
}

No push Example

const FBMessenger = require('fb-messenger')
const messenger = new FBMessenger({token: '<YOUR TOKEN>'})

messenger.sendTextMessage({id: '<ID>', text: 'Hello', notificationType: 'NO_PUSH'})

Default to silent push Example

const FBMessenger = require('fb-messenger')
const messenger = new FBMessenger({token: '<YOUR TOKEN>', notificationType: 'SILENT_PUSH'})

Complete Example

const FBMessenger = require('fb-messenger')
const messenger = new FBMessenger({token: '<YOUR TOKEN>', notificationType: 'NO_PUSH'})

try {
  await messenger.sendTextMessage({id: '<ID>', text: 'Hello'}) // Send a message with NO_PUSH, ignoring response
  console.log('Sent successfully')
} catch(e) {
  console.error(e)
}

// Send an image overriding default notification type with callback
try {
  const response = await messenger.sendImageMessage({id: '<ID>', url: '<IMG URL>', notificationType: 'REGULAR'})
  console.log('Sent image, response:')
  console.dir(response)
} catch(e) {
  console.error(e)
}

messenger.sendTextMessage({id: '<ID>', text: 'Hello', token: '<YOUR OTHER TOKEN>'}) // Send message on another page

License

MIT. Copyright © Diego Rodríguez Baquero

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].