GithubHelp home page GithubHelp logo

petrbela / messenger-bot-rails Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jun85664396/messenger-bot-rails

0.0 1.0 0.0 32 KB

Ruby on Rails Gem for the Facebook Messenger Bot Platform

License: MIT License

Ruby 98.61% Shell 1.39%

messenger-bot-rails's Introduction

#messenger-bot Build Status Gem Version

Ruby on Rails client!! for Facebook Messenger Platform

Requires Rails >= 4

##Installation

Bundler in your Gemfile.

gem 'messenger-bot'

##Getting Started

####Before You Begin Now sign in into the Facebook developer and create an application

  1. Add messenger-bot-rails to your Gemfile
gem 'messenger-bot'
  1. Set config in config/initializers/messenger_bot.rb
Messenger::Bot.config do |config|
  config.access_token = <PAGE_ACCESS_TOKEN>
  config.validation_token = <VERIFY_TOKEN>
  config.secret_token = <FB_APP_SECRET_TOKEN>
end

Subscribe the App to the Page

  1. Add the following to your config/routes.rb
mount Messenger::Bot::Space => "/webhook"
  1. create a controller in app/controllers/messenger_bot_controller.rb
class MessengerBotController < ActionController::Base
  def message(event, sender)
    # profile = sender.get_profile(field) # default field [:locale, :timezone, :gender, :first_name, :last_name, :profile_pic]
    sender.reply({ text: "Reply: #{event['message']['text']}" })
  end

  def delivery(event, sender)
  end

  def postback(event, sender)
    payload = event["postback"]["payload"]
    case payload
    when :something
      #ex) process sender.reply({text: "button click event!"})
    end
  end
end

wiki

##Usage

###message(event, sender)

  • event - Hash containing the message event from Facebook format
  • sender - Class to call the 'reply, get_profile' method.

###delivery(event, sender)

  • event - Hash containing the delivery event from Facebook format
  • sender - Class to call the 'reply, get_profile' method.

###postback(event, sender)

  • event - Hash containing the postback event from Facebook format
  • sender - Class to call the 'reply, get_profile' method.

###optin(event, sender)

  • event - Hash containing the optin event from Facebook format
  • sender - Class to call the 'reply, get_profile' method.

license

MIT, see LICENSE.txt

messenger-bot-rails's People

Contributors

baleen37 avatar devilankur18 avatar jkubacki avatar jun85664396 avatar matthiasrms avatar

Watchers

 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.