View Source WhatsappElixir.Messages (whatsapp_elixir v0.1.1)

Module to handle WhatsApp messaging.

Link to this section Summary

Link to this section Functions

Link to this function

mark_as_read(message_id, custom_config \\ [])

View Source

Marks a message as read.

Link to this function

reply(data, reply_text \\ "", custom_config \\ [], preview_url \\ true)

View Source

Replies to a message with a given text.

Link to this function

send_message(to, content, custom_config \\ [], preview_url \\ true)

View Source

Sends a text message.

Link to this function

send_template(template, recipient_id, components, lang \\ "en_US", custom_config \\ [])

View Source

## Parameters

  • template: The name of the template to be sent.
  • recipient_id: The recipient's WhatsApp ID.
  • components: A list of components (e.g., buttons, text) to include in the template message.
  • lang: (Optional) The language code for the message. Defaults to "en_US".
  • custom_config: (Optional) A list of custom configuration options for the HTTP request.

Examples

iex> send_template("hello_world", "+2547111111111""}])
{:ok, %{"status" => "sent"}}

iex> send_template("welcome_template", "+2547111111111"", [], "fr_FR" , custom_configs)
{:ok, %{"status" => "sent"}}

Returns

  • {:ok, response}: On success, returns :ok and the HTTP response.
  • {:error, response}: On failure, returns :error and the HTTP response.