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
| Scope | Purpose |
|---|---|
canned_responses:read | List, get and render canned responses |
canned_responses:create / :update / :delete | Manage your own canned responses |
canned_responses:settings | Create shared canned responses and edit anyone's |
messages:create | Manage, 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:
| Variable | Resolves 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:
- its value (if not empty),
- the fallback in
variable_defaults, - 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 field | Type | Description |
|---|---|---|
conversation_id | string, optional | Conversation 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:readorcontacts:read. Conversation variables needconversations: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 field | Type | Description |
|---|---|---|
channel_id | string | WhatsApp channel to send from |
contact_id | string | The recipient |
conversation_id | string, optional | Conversation 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. |
meta | object, optional | Your 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 "…".
| Field | WhatsApp limit |
|---|---|
| Body | 1024 |
| Header text, footer | 60 |
| Button title | 20 |
| List section title, row title | 24 |
| Row description | 72 |
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 field | Type | Description |
|---|---|---|
conversation_id | string, required | Conversation 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 isnull(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 inempty_fieldswith the samefieldpath andvariablesthat/sendwould return in its422 interactive_variable_emptyerror. An emptyempty_fieldslist means the send would go through. missing_variableslists every variable, in any field, that had no value and no fallback, each once, in the order first found.buttonsandsectionskeep their other keys, such asid.- 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:readorcontacts:read, andconversation.assigned_agent.*only withconversations:read. Without them those variables use their fallbacks, so the preview can differ from what/sendsends.
Next Steps
- Interactive Messages: send buttons and lists without saving a template
- Contacts: custom fields