PhoenixFacebookMessenger v0.4.0 FacebookMessenger.Phoenix.Router

Router module, this module will be responsible to defines the default routes needed for facebook bot communication.

The routes are - get /api/webhook for challenges - post /api/webhook for webhook communication

Summary

Macros

function responsible for defining the routes used for facebook messenger bot communication

Macros

facebook_routes(path, controller)

Specs

facebook_routes(term, String.t, module) :: any

function responsible for defining the routes used for facebook messenger bot communication

The routes are: - get /api/webhook for challenges - post /api/webhook for webhook communication

It takes a controller that use FacebookMessenger.Controller

Example: in test_controller.ex

defmodule TestController do
  use FacebookMessenger.Controller

  def message_received(msg) do
    ....
  end
end

Then in routes.ex

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

  # Add these two lines
  use FacebookMessenger.Router
  facebook_routes TestController
end

Parameters:

  • path the webhook path you want to use to receive webhook events
  • controller the controller that use FacebookMessenger.Controller