README.md

# Xend

[![Build Status](https://travis-ci.org/saulecabrera/xend.svg?branch=master)](https://travis-ci.org/saulecabrera/xend)


Simple Elixir wrapper for [Facebook's Send API](https://developers.facebook.com/docs/messenger-platform/send-api-reference)


## Usage
 
Add xend as a dependency in your `mix.exs`:

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

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

```elixir
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](https://developers.facebook.com/docs/messenger-platform/send-api-reference) for more information on notification types.


### Sending a text message

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

### Sending a text message with predefined replies

```elixir
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

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

### Sender action

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