Xend

Build Status

Simple Elixir wrapper for Facebook's Send API

Usage

Add xend as a dependency in your mix.exs:

defp deps do
[
{:xend, "~> 0.6.0"}
]
end

Add your facebook's page access token to your configuration for xend:

config :xend,
fb_page_access_token: System.get_env("FB_PAGE_ACCESS_TOKEN")

Notification types

text/3, text/4 and attachment/3 functions receive as a last argument a notification type, which can be: "REGULAR", "SILENT_PUSH", "NO_PUSH". Refer to the Send API documentation for more information on notification types.

Sending a text message

Xend.text("USER_ID", "Hello World", "REGULAR")

Sending a text message with predefined replies

quick_replies = [%{content_type: "text", title: "Yes", payload: ""}, %{content_type: "text", title: "No", payload: ""}]
Xend.text("USER_ID", "Do you want ketchup with your order?", quick_replies, "REGULAR")

Sending an attachment

attachment = %{
type: "image",
payload: %{
url: "https://petersapparel.parseapp.com/img/shirt.png"
}
}
Xend.attachment("USER_ID", attachment, "REGULAR")

Sender action

Xend.action("USER_ID", :mark_seen)
Xend.action("USER_ID", :typing_on)
Xend.action("USER_ID", :typing_off)