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.:

msg, err := client.Messages.SendOne(ctx, goomzo.MessageInput{
	To:        "+255712345678",
	Template:  goomzo.SavedTemplate("auth_1"),
	Variables: map[string]string{"code": "482913", "minutes": "10"},
}, goomzo.WithIdempotencyKey("login-"+attemptID))

msg.Private      // true
msg.Content.Text // "Your code is ••••••. It expires in 10 minutes."

To send an approved WhatsApp template directly, use goomzo.WhatsAppTemplateByID(id, values) instead.

Manage templates

_, err := client.Templates.Create(ctx, goomzo.TemplateInput{
	Name:     "auth_1",
	Channel:  goomzo.SMS,
	Category: goomzo.Authentication,
	Content:  &goomzo.Content{Text: "Your code is {{secret.code}}. It expires in {{data.minutes}} minutes."},
})

templates, err := client.Templates.List(ctx, goomzo.TemplateListParams{Channel: goomzo.SMS})
MethodDoes
Templates.List(ctx, params)Lists your templates, by Channel or Category.
Templates.Get(ctx, id)Gets one.
Templates.Create(ctx, template)Saves one. A WhatsApp one can be submitted to Meta.
Templates.Update(ctx, id, changes)Changes one.
Templates.Delete(ctx, id)Deletes one.
WhatsApp.Templates.List(ctx, approved)Lists the templates on your WhatsApp account.

Next steps

Last updated