Helpers for building template message components.
Template messages require pre-approved templates registered in the WhatsApp Business Manager. These helpers build the component parameters that fill in the template placeholders.
Examples
Anu.Message.new("+5511999999999")
|> Anu.Message.template("order_update", "en_US", [
Anu.Template.body_param("John"),
Anu.Template.body_param("#12345")
])
Summary
Functions
Creates a text parameter for the template body.
Creates a button parameter for a template button.
Creates a document parameter for the template header.
Creates an image parameter for the template header.
Types
@type param() :: map()
Functions
Creates a text parameter for the template body.
Examples
iex> Anu.Template.body_param("John")
%{type: "text", text: "John"}
Creates a button parameter for a template button.
Types
"url"- URL suffix appended to the button URL"quick_reply"- payload sent back when user taps the button
Examples
iex> Anu.Template.button_param("url", "/track/12345")
%{type: "url", url: "/track/12345"}
iex> Anu.Template.button_param("quick_reply", "confirm_yes")
%{type: "quick_reply", payload: "confirm_yes"}
Creates a document parameter for the template header.
Examples
iex> Anu.Template.header_document("https://example.com/doc.pdf", "invoice.pdf")
%{type: "document", document: %{link: "https://example.com/doc.pdf", filename: "invoice.pdf"}}
Creates an image parameter for the template header.
Examples
iex> Anu.Template.header_image("https://example.com/img.png")
%{type: "image", image: %{link: "https://example.com/img.png"}}