Send templates
Send a saved template, such as a verification code, by name.
Send a saved template by its name, with the values it needs. {{secret.x}} values are delivered, but kept as
••••••. See Send templates.
Send a template
For a template auth_1 that reads Your code is {{secret.code}}. It expires in {{data.minutes}} minutes.:
const message = await goomzo.messages.sendOne(
{ to: '+255712345678', template: 'auth_1', variables: { code: '482913', minutes: '10' } },
{ idempotencyKey: `login-${attemptId}` },
)
message.private // true
message.content?.text // "Your code is ••••••. It expires in 10 minutes."Manage templates
await goomzo.templates.create({
name: 'auth_1',
channel: 'sms',
category: 'authentication',
content: { text: 'Your code is {{secret.code}}. It expires in {{data.minutes}} minutes.' },
})
const { items } = await goomzo.templates.list({ channel: 'sms' })| Method | Does |
|---|---|
templates.list(query) | Lists your templates, by channel or category. |
templates.get(id) | Gets one. |
templates.create(body) | Saves one. A WhatsApp one can be submitted to Meta. |
templates.update(id, body) | Changes one. |
templates.delete(id) | Deletes one. |
templates.library(query) | Lists the ready-made templates in the library. |
templates.useLibrary(id, body) | Saves your own copy of a library template under your name. |
whatsapp.templates.list() | Lists the templates on your WhatsApp account. |
Next steps
Last updated