Skip to content

PhoenixFacebookMessenger is a library that helps you create facebook messenger bots easily with phoenix.

Notifications You must be signed in to change notification settings

nsomar/phoenix_facebook_messenger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PhoenixFacebookMessenger

Build Status Hex.pm API Docs Coverage Status Inline docs

Phoenix Facebook Messenger is a library that easy the creation of facebook messenger bots.

Installation

def deps do
  [{:phoenix_facebook_messenger, "~> 0.2.0"}]
end

Requirements

  • a Phoenix App with phoenix 1.1 and up

Usage

With Phoenix

You need to have a working phoenix app to use phoenix_facebook_messenger.

To create an echo back bot, do the following:

Create a new controller web/controller/test_controller.ex

defmodule TestController do
  use FacebookMessenger.Phoenix.Controller

  def message_received(msg) do
    text = FacebookMessenger.Response.message_texts(msg) |> hd
    sender = FacebookMessenger.Response.message_senders(msg) |> hd
    FacebookMessenger.Sender.send(sender, text)
  end
end

Add the required routes in web/router.ex

defmodule YourApp.Router do
  use YourApp.Web, :router

  # Add these two lines
  use FacebookMessenger.Phoenix.Router
  facebook_routes "/api/webhook", TestController
end

This defines a webhook endpoint at: http://your-app-url/api/webhook

Go to your config/config.exs and add the required configurations

config :facebook_messenger,
      facebook_page_token: "Your facebook page token",
      challenge_verification_token: "the challenge verify token"

To get the facebook_page_token and challenge_verification_token follow the instructions here

For the webhook endpoint use http://your-app-url/api/webhook

With plug

If you use plug in your project, then you need the plug version of facebook_messenger this can be found at found here.

Sample

About

PhoenixFacebookMessenger is a library that helps you create facebook messenger bots easily with phoenix.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages