WhatsappElixir.Others (whatsapp_elixir v0.1.9)

View Source

Module to handle sending custom JSON and contact messages to WhatsApp users.

Summary

Functions

Sends a list of contacts to a WhatsApp user.

Sends a custom JSON to a WhatsApp user. This can be used to send custom objects to the message endpoint.

Functions

send_contacts(contacts, recipient_id, custom_config \\ [])

Sends a list of contacts to a WhatsApp user.

REFERENCE: https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#contacts-object

Examples

iex> contacts = [%{
...>  "name" => %{ "formatted_name" => "Maxwell Muhanda", "first_name" => "Maxwell" },
...>   "addresses" => [%{
...>     "street" => "STREET",
...>     "city" => "CITY",
...>     "state" => "STATE",
...>     "zip" => "ZIP",
...>     "country" => "COUNTRY",
...>     "country_code" => "COUNTRY_CODE",
...>     "type" => "HOME"
...>   }]
...> }]
iex> recipient_id = "5511999999999"
iex> WhatsappElixir.Others.send_contacts(contacts, recipient_id)

send_custom_json(data, recipient_id \\ "", custom_config \\ [])

Sends a custom JSON to a WhatsApp user. This can be used to send custom objects to the message endpoint.

Examples

iex> data = %{
...>   "messaging_product" => "whatsapp",
...>   "type" => "audio",
...>   "audio" => %{"id" => "audio_id"}
...> }
iex> recipient_id = "5511999999999"
iex> WhatsappElixir.Others.send_custom_json(data, recipient_id)