Skip to main content
Templates.whatsapp lists the WhatsApp message templates on one of the agent’s WhatsApp channels and sends one to a list of phone numbers. To send a template to one end user as part of their conversation, with a delivery record, use Channels.whatsapp.sendTemplate instead. Marketplace agent templates are a different thing; see lua marketplace. Available in tools, jobs, webhooks, triggers, processors, and workflow code steps. Verified against lua-cli 3.33.0.

Quick example

Find the channel id with lua channels list, then pass it to every call.

Methods

whatsapp.list(channelId, options?)

Lists the channel’s templates, paginated, optionally filtered by name.
string
required
The WhatsApp channel identifier from lua channels list.
number
default:1
Page number, starting at 1.
number
default:10
Templates per page.
Filters templates by name.
Returns
PaginatedTemplatesResponse
Example
ErrorsFailed to list templates when the platform gives no message.

whatsapp.get(channelId, templateId)

Reads one template with its components.
string
required
The WhatsApp channel identifier.
string
required
Meta’s numeric template id, or the template’s exact name (case-insensitive).
Returns — a WhatsAppTemplate. Example
ErrorsTemplate "<name>" not found. Use a numeric template ID or an exact template name.; Failed to get template when the platform gives no message.

whatsapp.send(channelId, templateId, data)

Sends one approved template to a list of phone numbers and reports the outcome per recipient.
string
required
The WhatsApp channel identifier.
string
required
Meta’s numeric template id, or the template’s exact name (case-insensitive). The template must be APPROVED.
string[]
required
Recipients in E.164 form. A leading +, spaces, and dashes are stripped; entries with no digits are dropped.
Record<string, string>
Header parameters. For a media header, pass the public HTTPS URL as image_url, video_url, or document_url (plus document_filename), or a Meta media id as image_id, video_id, or document_id. A media id wins when both are given.
Record<string, string>
Body parameters keyed by the template’s parameter names.
Array<{ sub_type, index, text?, coupon_code? }>
Button parameters; sub_type is QUICK_REPLY, URL, PHONE_NUMBER, or COPY_CODE, and index the button’s position as a string.
Returns
SendTemplateResponse
Recipients are processed in batches of 10 with a one-second pause between batches and 30 seconds per recipient. Entries keep recipient order but don’t carry the phone number; send one recipient per call when you need to correlate.
Example
ErrorsTemplate must be approved before sending; Template "<name>" not found. Use a numeric template ID or an exact template name.; No valid recipient phone numbers (numbers must contain digits); a 400 naming the component when a parameter value is missing or extra; Failed to send template when the platform gives no message.

Types

interface
page?, limit?, search?.
interface
The result of list.
interface
interface
phoneNumbers and values? (a SendTemplateValues), as on send.
interface
The result of send. results and errors are typed any[].

See also