Skip to main content

Canned Responses & Saved Interactive Messages

Message templates for agents come in two kinds:

  • Canned responses: reusable text replies (/api/v1/canned-responses), inserted into the composer with a shortcut like /greeting.
  • Saved interactive messages: WhatsApp button and list messages (/api/v1/saved-interactive-messages), sent to a contact in one call.

Both can contain variables such as {{contact.first_name}}, and both store fallback values per variable in variable_defaults.

Required Scopes​

ScopePurpose
canned_responses:readList, get and render canned responses
canned_responses:create / :update / :deleteManage your own canned responses
canned_responses:settingsCreate shared canned responses and edit anyone's
messages:createManage, preview and send saved interactive messages

For API keys and OAuth apps, canned_responses:settings must be in the token's own scopes (this also covers seeing and editing everyone's saved interactive messages). The role of the user who created the token does not count.

Variables​

Write variables as {{namespace.field}}. They resolve when a canned response is rendered or a saved interactive message is sent:

VariableResolves to
{{contact.first_name}}, {{contact.last_name}}, {{contact.name}}, {{contact.email}}, {{contact.phone}}, {{contact.birthday}}The conversation's contact (the recipient)
{{contact.custom.<key>}}A custom field of the contact
{{contact.owner_name}}, {{contact.owner_email}}, {{contact.owner_id}}The contact's owner
{{conversation.assigned_agent.display_name}} (also nickname, email, phone, job_title, id)The agent the conversation is assigned to
{{agent.name}}, {{agent.first_name}}, {{agent.last_name}}, {{agent.email}}, {{agent.phone}}, {{agent.job_title}}, {{agent.role}}You, the agent rendering or sending
{{company.name}} (and the other company profile fields)Your company profile
{{system.year}}, {{system.date}}, {{now}}Current year, date, UTC timestamp

Fallback values​

Each variable resolves in this order:

  1. its value (if not empty),
  2. the fallback in variable_defaults,
  3. an empty string.

A placeholder like {{contact.first_name}} is never sent literally.

variable_defaults is an object of variable name to fallback text. Keys may be written with or without braces ("contact.first_name" or "{{contact.first_name}}") and are stored without them. Limits: 100 entries, keys up to 200 characters, values up to 1,000 characters, strings only. A fallback is plain text: a variable inside a fallback is removed, not resolved.

On update (PUT), leave variable_defaults out to keep the current fallbacks, or send null or {} to remove them all.

{
"title": "Greeting",
"shortcut": "greeting",
"content": "Hi {{contact.first_name}}, this is {{agent.first_name}}. How can I help?",
"variable_defaults": {
"contact.first_name": "there"
}
}

Render a canned response​

POST /api/v1/canned-responses/{id}/render returns the content with every variable resolved, ready to put in the composer.

Body fieldTypeDescription
conversation_idstring, optionalConversation to resolve contact and conversation variables against. Leave it out to use fallbacks only.
curl -X POST "https://api.sendseven.com/api/v1/canned-responses/CANNED_ID/render" \
-H "Authorization: Bearer $SENDSEVEN_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"conversation_id": "CONVERSATION_ID"}'
{
"content": "Hi there, this is Anna. How can I help?",
"missing_variables": []
}

missing_variables lists the variables that had no value and no fallback, so they were left empty.

Rules:

  • The canned response must be visible to you: your own, or shared. Otherwise you get 404.
  • The conversation must belong to your workspace and be one you can open. Otherwise you get 404.
  • Contact variables use the conversation's contact only if you also hold conversations:read or contacts:read. Conversation variables need conversations:read. Without these scopes, those variables use their fallbacks.

Send a saved interactive message​

POST /api/v1/saved-interactive-messages/{id}/send sends the template to a contact over a WhatsApp channel.

Body fieldTypeDescription
channel_idstringWhatsApp channel to send from
contact_idstringThe recipient
conversation_idstring, optionalConversation for the conversation.* variables. It must belong to the recipient and be one you can open, otherwise 404. Leave it out to use the conversation the message is sent into.
metaobject, optionalYour own metadata for the message

Variables are resolved when the message is sent, in the body, header text, footer, button titles, list section titles, row titles and row descriptions. Fallbacks come from the template's variable_defaults.

Length limits​

WhatsApp limits field lengths. A plain-text title must fit the limit when you save it. A title that contains a variable can be up to 200 characters when you save it, because its final length depends on the contact. When the message is sent, any resolved text that is too long is cut to the limit and ends with "…".

FieldWhatsApp limit
Body1024
Header text, footer60
Button title20
List section title, row title24
Row description72

Empty fields​

If an optional field (header text, footer, row description, or the title of a list's only section) is empty after the variables are filled, it is left out. If a required field is empty, nothing is sent and you get 422. Required fields are the body, every button title, every row title, and the section titles of a list with more than one section.

{
"detail": {
"code": "interactive_variable_empty",
"field": "buttons[0].title",
"variables": ["contact.first_name"],
"message": "'buttons[0].title' is empty after filling contact.first_name. Add a fallback value for these variables or fill them on the contact."
}
}

To avoid this, add a fallback in variable_defaults for every variable used in a required field.

Preview a saved interactive message​

POST /api/v1/saved-interactive-messages/{id}/render returns the text exactly as /send would send it to a conversation's contact, without sending or storing anything. Use it to show the filled-in message before the agent sends it.

Body fieldTypeDescription
conversation_idstring, requiredConversation to render against: its contact, its assigned agent, and you as the sending agent
curl -X POST "https://api.sendseven.com/api/v1/saved-interactive-messages/MESSAGE_ID/render" \
-H "Authorization: Bearer $SENDSEVEN_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"conversation_id": "CONVERSATION_ID"}'
{
"body": "",
"header_text": "For Anna Schmidt",
"footer_text": null,
"button_text": null,
"buttons": [
{"id": "b1", "title": "Yes Anna"},
{"id": "b2", "title": "No"}
],
"sections": null,
"missing_variables": ["contact.custom.order_id", "company.name"],
"empty_fields": [
{"field": "body", "variables": ["contact.custom.order_id"]}
]
}
  • The same fallbacks, length limits and optional-field rules apply as for /send. An optional field that ends empty is null (header text, footer, button text) or left out (row description, title of a list's only section).
  • A required field that ends empty does not fail here. It stays "" and is listed in empty_fields with the same field path and variables that /send would return in its 422 interactive_variable_empty error. An empty empty_fields list means the send would go through.
  • missing_variables lists every variable, in any field, that had no value and no fallback, each once, in the order first found.
  • buttons and sections keep their other keys, such as id.
  • The saved message must be yours or shared, and the conversation one you can open whose contact you can see. Otherwise you get 404.
  • Contact variables resolve only when your token or role also holds conversations:read or contacts:read, and conversation.assigned_agent.* only with conversations:read. Without them those variables use their fallbacks, so the preview can differ from what /send sends.

Next Steps​