Coder Social home page Coder Social logo

kyroskoh / serverless-facebook-messenger-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from michalsanger/serverless-facebook-messenger-bot

0.0 2.0 0.0 18 KB

Serverless backend for Facebook Messenger Bot

License: MIT License

JavaScript 100.00%

serverless-facebook-messenger-bot's Introduction

Serverless Facebook Messenger Bot

Build Status

Serverless backend for Facebook Messenger Bot

Demo - not working yet, it takes time to review the app :-(

Send message, photo, location, anything Messenger supports.

Install

You need to have installed the Serverless Framework (version 0.5.2 or higher) and you're using Node.js v4.0+.

1. Init project

sls project install serverless-facebook-messenger-bot

2. Setup FB App

Follow quickstart but start with Step 1 and Step 3 to get Page Access Token before deploying backend.

3. Set variables

sls variables set -k PAGE_ACCESS_TOKEN
sls variables set -k VERIFY_TOKEN

VERIFY_TOKEN is used for subsciption verification.

4. Deploy backend app

Deploy all functions and endpoints

sls function deploy --all
sls endpoint deploy --all

Now you have public webhook URL.

5. Setup Webhook

Back to the FB App Quickstart and verify your webhook.

6. Subscribe the App to the Page

curl -ik -X POST "https://graph.facebook.com/v2.6/me/subscribed_apps?access_token=<PAGE_ACCESS_TOKEN>"

7. Send messages

Go to your Facebook Page and send a message to it. The response will come from your brand new servreless backend! See screenshots in the Quickstart

Running Tests

npm test

Develop

Want to add some logic into bot's responses? Take a look in functions/webhook/handlers/

Deploy

sls function deploy --all

Running localy

npm run offline

and you can send POST requests to http://localhost:3000/webhook

To get an idea about the POST body, enable logging:

sls variables set -k LOG_WEBHOOK_MESSAGES -v true

deploy, send few messages via Messenger and see the logs:

sls function logs webhook

serverless-facebook-messenger-bot's People

Contributors

michalsanger avatar jeffcarp avatar

Watchers

Kyros Koh avatar  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.