Variables, constants and buttons in scenarios
How to insert request and contact data into messages, keep shared values in company constants, add buttons and branch a scenario on the client reply.
Placeholders in step text
Placeholders like {{ path }} work in all text fields of steps (message, request address and body, header). The easiest way is the "Insert variable" button: it lists only what exists in your scenario.
| Path start | What it holds |
|---|---|
trigger | Start data. For a webhook: {{trigger.body.Field name}}, for other triggers the event fields. |
contact | Contact data: {{contact.name}}, {{contact.phone}}, {{contact.email}}, {{contact.tags}}. |
vars | Scenario variables: {{vars.name}}. They are set by the "Set variable" step, the contact request and by saving the answer of an external request. |
const | Company constants: {{const.site_url}}. |
nodes | Results of previous steps. |
- If the root is known but there is no value, an empty string is substituted. An unknown root stays in the text as it is.
- A list or an object is substituted as compact JSON.
- In a request address, values from the request or a contact cannot be placed in the part before the first slash (the server address): only text or a company constant is allowed there. Variables are allowed in the path and parameters.
Scenario variables
The "Set variable" step (set-variable) writes a value into a run variable: set, increment or decrement (change a number), clear. The name starts with a Latin letter, then letters, digits, underscore, up to 64 characters. A single run holds at most 50 variables, a value is up to 8 KB. When a limit is exceeded the step ends with an error and the run continues.
The answer of an external request can also be saved into variables: in the request step give a path in the JSON answer, for example $.data.id, and a variable name (several fields are allowed). In a test run the request is not sent, so the variables stay empty.
The "Extract by pattern" operation (extract) takes text from the value field ({{…}} placeholders work only there), finds the first regular expression match and puts the chosen capture group into the variable: by number or by name (capture_group, empty means the whole match). The pattern (pattern) and the flags i, m, s (regex_flags) are entered literally, with no variable substitution. The first 8 KB of the text are checked. No match or no such group: the variable is cleared and the step does not fail. A broken pattern or exceeded limits end the step with an error and the run continues. Example: from "My order №4512" the pattern №(\d+) puts 4512 into vars.order. More about patterns: conditions and flow control.
The "Find contact", "Find deal" and "Get field value" blocks also write into variables: the ID of what they found (found_contact_id and found_deal_id by default) and the values of the chosen fields, such as the deal amount. These variables work in conditions and placeholders like any other: {{vars.found_deal_id}} is taken by "Move deal stage" and "Delete". If nothing is found, the block variables are cleared. In detail: CRM blocks in scenarios.
Company constants
A constant is a value shared by all scenarios of the company: a website address, a price-list link, a contact number. You change it in one place and every scenario updates. Manage them in the scenario editor via "Company constants...".
- Key: lowercase Latin letters, digits and underscore, starts with a letter, up to 64 characters. Example:
site_url. - The value is up to 2000 characters, the description up to 255. At most 100 constants per company.
- Do not store passwords or access keys in constants: everyone who can edit scenarios sees them.
- If you delete a constant used in a scenario, the placeholder becomes empty. AISAR does not check this in advance, a warning is shown in the delete dialog.
Over the API constants are available at GET, POST /v1/automations/constants and PATCH, DELETE /v1/automations/constants/{constant}. More: REST, automations.
Buttons in a message
A message step can carry buttons ("Add button"): at most 10, a button label up to 80 characters. Each button gets its own branch on the canvas.
| Channel | How the buttons look |
|---|---|
| WhatsApp Business | Reply buttons, up to 3, label up to 20 characters. |
| Telegram Bot | Inline buttons, up to 10. |
| Instagram, Messenger | Quick replies, up to 13, label up to 20 characters. |
| Personal WhatsApp (QR), Telegram Business, email | A numbered list in the text: 1. Name. The client answers with the number or the name. |
If there are more buttons than the channel can show, or a label is longer than the limit, the message goes out as a numbered list and nothing is lost. Buttons do not apply in voice message mode.
Branching on the client reply
After a step with buttons add "Wait for reply" and turn on the branching mode. The step outputs are then:
- one branch per button;
- "Something else": the client answered with text that matches no button (the branch works only if a link is connected to it);
- "No answer after N": the wait time ran out. In this mode the wait time is mandatory: minutes, hours or days, from 1 minute to 30 days, 24 hours by default. On the canvas the branch is labelled, for example, "No answer after 2 h". The "Working hours" switch (off by default) counts minutes and hours only inside the company work schedule and days as working days; with no schedule the time is calendar time.
Without buttons there are two outputs: "Replied" and "No answer after N". With branching off the step works as before: a timer pause, and when the client answers the branch ends. A client message the scenario accepted as a reply does not start the AI agent and does not start the same scenario "Message received" trigger.
Asking for a phone or an email
The "Ask for phone or email" step (request-contact) asks the client to send a contact. If the value is already on the card, no message is sent and the scenario goes on along the "Contact received" branch. In Telegram Bot a button to share the number is shown for a phone (private chat only), in other channels the request goes as text. A number from a Telegram contact is accepted only if it belongs to the client. After the step add "Wait for reply" with branching.
Collecting data: "Ask and save"
The "Ask and save" block (ask-question) asks the client a question, checks the answer, asks again on a wrong answer and writes the result to a variable, a card field or the contact. The question, the wait and the check live in one block: no separate "Wait for reply" is needed after it. The question goes out in the channel of the run conversation, or in the channel chosen in the block.
| Answer type | What is accepted | What is saved |
|---|---|---|
| Text | Any non-empty answer. | The first 1000 characters. |
| Number | 12 or 12.5, up to six decimal places. You can set "From" and "To" bounds. | A number with a dot: 12.5. |
| Phone | A WhatsApp contact card or one number in the text. | International format by the company country: +12025550147. |
| Exactly one address. | In lowercase. | |
| Date | 25.11.2026, 25.11.26, 25/11/2026, 2026-11-25. A date that does not exist (31.02) is not accepted. | As 2026-11-25. |
| Choice from a list | From 1 to 10 options, a label up to 64 characters. The client taps a button or writes the option number or label (case does not matter). | The option label. |
| Pattern | The regular expression must be found in the answer text. You can check a pattern in advance, see REST, automations. | The whole answer. |
A sticker or a photo without a caption counts as a wrong answer and uses up an attempt.
Attempts and waiting
- "Attempts in total": from 1 to 5, 3 by default. The first question counts as an attempt too; 1 means "do not ask again".
- "Re-ask text" is optional: if empty, the question is repeated as it was. Placeholders
{{…}}work in both texts, up to 4096 characters. - "How long to wait": minutes, hours or days, from 1 minute to 30 days, empty means 24 hours. The term restarts after every question and re-ask.
- The "Working hours" switch (off by default): minutes and hours count only inside the company work schedule, days count as working days. The overall ceiling stays 30 calendar days. If no schedule is set, time counts as calendar time.
Where to save the answer
- "Variable" is required: the name starts with a Latin letter, then letters, digits and
_, up to 64 characters. Further in the scenario the answer is available as{{vars.name}}. - "Write to field": additionally put the answer into a contact field or a custom contact or conversation field, the same way the "Update field" step does. Archived and protected fields cannot be chosen.
- "Add to contact" (phone and e-mail only): add the number or address to the contact. If it already belongs to another contact, it is not added to the card and the run keeps a note.
- "Do not overwrite a filled field" is on by default: what an operator has already entered in the card is not overwritten by the client answer. The run variable is filled in any case. Turn the switch off if the answer must replace the old value.
If a field was not written (for example it is archived) or already holds a value, the exit stays "Collected" and the step result carries a note (field_already_filled, identifier_already_filled, identifier_belongs_to_other_contact and codes like field_…). The answer text does not go into the run log: it is kept only in the variable and the chosen fields.
Exits and reasons
| Exit | When |
|---|---|
| Collected | A valid answer was received and saved. |
| Failed | Attempts ran out, the question could not be sent or the block cannot run. The reason is written to the log. |
| No answer after … | The client did not answer within the set time. |
| Reason ("Failed" exit) | What it means |
|---|---|
attempts_exhausted | All attempts were spent on wrong answers. |
send_failed | The question or the re-ask was not sent: the 24-hour window is closed, the contact is blocked, quiet hours and other sending reasons. |
no_contact | The run has no contact. |
group_dialog_not_supported | The block does not work in group conversations. |
invalid_config | The block is misconfigured, for example an unknown answer type. |
variable_limit | The run already holds 50 variables or the value is too large. |
kids_not_supported | The block is not available in Kids companies. |
In a test run the question is not sent and the run goes along the "No answer after …" exit. When the scenario ends, the platform can send the automation.run.finished webhook event: it carries run metadata only, so pass the collected answers with the "Send webhook" step on the "Collected" exit. More: Automations: basics.
A WhatsApp Business template in a scenario
The "Send WhatsApp template" step (send-whatsapp-template) sends the client a Meta-approved template. In the step settings choose a WhatsApp Business channel and a template and fill in its variables: type a text or insert a value, for example {{contact.name}} or {{trigger.body.Name}}. The template must be approved and belong to the chosen channel.
For a run started from a webhook request this is the only way to write to the client first in WhatsApp Business outside the 24-hour window: a template can open the dialog, while plain text outside the window is skipped (the reason is whatsapp_window_closed). AISAR normalizes the variable values to what Meta accepts: line breaks and long runs of spaces are replaced, and a value that is too long is cut.
If the template has quick reply buttons (quick_reply), put "Wait for reply" with the branching mode as the next step: the client taps a button and the scenario follows the branch of that button, as in the section above. Link and call buttons do not take part in branching.
Why a message was not sent
If a step did not send a message, the scenario does not fail: the step is marked as skipped and the reason is written to the run log.
| Code | What it means |
|---|---|
whatsapp_window_closed, instagram_window_closed, messenger_window_closed | The 24-hour window is closed, plain text cannot be sent. In WhatsApp Business write first with a template. |
template_not_selected, template_not_found | No template is chosen or it was deleted. |
template_not_approved | The template is not yet approved by Meta or was rejected. |
template_channel_mismatch | The template belongs to another channel. |
template_param_missing | A template variable is not filled in or a placeholder gave an empty value. |
template_requires_waba | The template step works only in a WhatsApp Business channel. |
contact_opted_out | The client opted out of messages. |
contact_blocked, contact_hidden | The contact is blocked or hidden from the scenario. |
plan_message_limit | The outgoing message limit of the plan is used up, no new dialog was opened. |
channel_cannot_start_conversation | A dialog cannot be started first through this channel. |
quiet_hours, frequency_capped | It is the company quiet hours now or the client has already been written to too often. |
empty_body | The message text is empty. |
Open and close a conversation
- "Close conversation" (
close-conversation) closes the run conversation or the contact latest active one. A satisfaction survey is sent only if its option is on. - "Open conversation" (
open-conversation) opens a conversation or switches the scenario to the contact existing active one.