Wax.Messages.Message (wax v1.1.4)

The Whatsapp message

It defines a structure and main functions to work with it to modify the message to send

Summary

Functions

Adds an audio object to the message

Adds a document object to the message

Adds an image object to the message

Adds an interactive object to the message

Adds a template object to the message

Adds a video object to the message

Creates a new Message structure

Adds a text object to the message

Validates a message

Types

t()

@type t() :: %Wax.Messages.Message{
  audio: Wax.Messages.Media.t(),
  contacts: [Wax.Messages.Contact.t()],
  context: Wax.Messages.Context.t(),
  document: Wax.Messages.Media.t(),
  image: Wax.Messages.Media.t(),
  interactive: Wax.Messages.Interactive.t(),
  location: Wax.Messages.Location.t(),
  messaging_product: atom(),
  preview_url: boolean(),
  recipient_type: atom(),
  status: String.t(),
  template: Wax.Messages.Template.t(),
  text: Wax.Messages.Text.t(),
  to: whatsapp_id(),
  type: message_type(),
  video: Wax.Messages.Media.t()
}

Functions

add_audio(message, media_id)

@spec add_audio(t(), whatsapp_media_id()) :: t()

Adds an audio object to the message

add_document(message, media_id, filename, caption \\ nil)

@spec add_document(t(), whatsapp_media_id(), String.t(), String.t()) :: t()

Adds a document object to the message

add_image(message, media_id, caption \\ nil)

@spec add_image(t(), whatsapp_media_id(), String.t() | nil) :: t()

Adds an image object to the message

Images also accept a text caption that can be added on the same message

add_interactive(message, interactive)

@spec add_interactive(t(), Wax.Messages.Interactive.t()) :: t()

Adds an interactive object to the message

add_template(message, template)

@spec add_template(t(), Wax.Messages.Template.t()) :: t()

Adds a template object to the message

add_video(message, media_id, caption \\ nil)

@spec add_video(t(), whatsapp_media_id(), String.t() | nil) :: t()

Adds a video object to the message

Videos also accept a text caption that can be added on the same message

new(to)

@spec new(whatsapp_id()) :: t()

Creates a new Message structure

set_text(message, body, preview_url \\ false)

Adds a text object to the message

set_type(message, type)

@spec set_type(t(), String.t()) :: t()

validate(message)

@spec validate(t()) :: :ok | {:error, String.t()}

Validates a message

Checks if a message is valid to be sent to the Cloud API

#TODO: Move this functionality to its own module