Builders for WhatsApp session messages, sent with Unicom360.WhatsApp.send_session/3 inside
the 24-hour customer service window.
alias Unicom360.WhatsApp.Session
Session.text("260971234567", "Your order is ready.", reply_to: inbound_wamid)
Session.image("260971234567", "https://example.com/receipt.png", caption: "Your receipt")
Session.buttons("260971234567", "Collect today or deliver?", [
{"collect", "Collect"},
{"deliver", "Deliver"}
])Every builder takes the keyword options :from (your WhatsApp number), :user_reference_id
(makes the send safe to retry), :callback_url and, all but reaction/4, :reply_to.
:reply_to and a reaction's message_id take either a message_id a send returned or the
wamid. id of an inbound message, exactly as a message.received webhook delivers it.
The SDK checks no lengths or limits; the gateway answers an invalid message with an
:invalid_request_error.
Summary
Functions
An audio file.
An interactive message with up to three reply buttons, each a
Unicom360.WhatsApp.ReplyButton, an {id, title} tuple or a map. Options: :header,
:footer and the common ones.
Contact cards, each a map in Meta's contact shape
(%{"name" => %{"formatted_name" => ...}, "phones" => [...]}), sent as given.
A document, with an optional :caption and :filename.
An image, with an optional :caption.
An interactive list: button is the text of the button that opens it, sections a list of
Unicom360.WhatsApp.ListSection (or maps). Options: :header, :footer and the common ones.
A location pin. Options: :name, :address and the common ones.
A reaction to a message. An empty emoji ("") removes your reaction. Options: :from,
:user_reference_id and :callback_url (a reaction takes no :reply_to).
A sticker.
A text message. Options: the common ones.
A video, with an optional :caption.
Functions
@spec audio(String.t(), String.t(), keyword()) :: Unicom360.WhatsApp.SessionMessage.t()
An audio file.
@spec buttons( String.t(), String.t(), [Unicom360.WhatsApp.ReplyButton.t() | {String.t(), String.t()} | map()], keyword() ) :: Unicom360.WhatsApp.SessionMessage.t()
An interactive message with up to three reply buttons, each a
Unicom360.WhatsApp.ReplyButton, an {id, title} tuple or a map. Options: :header,
:footer and the common ones.
@spec contacts(String.t(), [map()], keyword()) :: Unicom360.WhatsApp.SessionMessage.t()
Contact cards, each a map in Meta's contact shape
(%{"name" => %{"formatted_name" => ...}, "phones" => [...]}), sent as given.
@spec document(String.t(), String.t(), keyword()) :: Unicom360.WhatsApp.SessionMessage.t()
A document, with an optional :caption and :filename.
@spec image(String.t(), String.t(), keyword()) :: Unicom360.WhatsApp.SessionMessage.t()
An image, with an optional :caption.
@spec list( String.t(), String.t(), String.t(), [Unicom360.WhatsApp.ListSection.t() | map()], keyword() ) :: Unicom360.WhatsApp.SessionMessage.t()
An interactive list: button is the text of the button that opens it, sections a list of
Unicom360.WhatsApp.ListSection (or maps). Options: :header, :footer and the common ones.
@spec location(String.t(), number(), number(), keyword()) :: Unicom360.WhatsApp.SessionMessage.t()
A location pin. Options: :name, :address and the common ones.
@spec reaction(String.t(), String.t(), String.t(), keyword()) :: Unicom360.WhatsApp.SessionMessage.t()
A reaction to a message. An empty emoji ("") removes your reaction. Options: :from,
:user_reference_id and :callback_url (a reaction takes no :reply_to).
@spec sticker(String.t(), String.t(), keyword()) :: Unicom360.WhatsApp.SessionMessage.t()
A sticker.
@spec text(String.t(), String.t(), keyword()) :: Unicom360.WhatsApp.SessionMessage.t()
A text message. Options: the common ones.
@spec video(String.t(), String.t(), keyword()) :: Unicom360.WhatsApp.SessionMessage.t()
A video, with an optional :caption.