Dynamic Buttons and Parameters
Buttons from a list, per-press parameters (Carry), and setting parameters via a button.
On this page
GetMyBot can build inline buttons from data, with one button per list element. Each button carries its own parameters, captured when the message is sent. This supports flows such as showing a catalog and using the customer's selection to place an order. Configure it in the "Send message" action's message block.
Dynamic buttons from a list
The "Dynamic buttons from list" block expands an array from ctx into a keyboard: one button per array element. Four things are configured:
- List: the key of the array in the context (
over), e.g.ctx.products. The array is usually placed there by a "Source query", "Web request", or compute action. - Element alias: the name under which the element is available in the template (
as, defaultitem). - Buttons per row: how many buttons to place on a single line (
columns, default1). - Button template: a normal button, but its text and fields support substitutions by alias:
{{item.name}},{{item.price}}, etc.
On send, the template is rendered for each element, resulting in as many buttons as there are elements in the list. This is how you build catalogs, collection record lists, and data-driven menus.
Example
ctx.products contains an array of objects with the fields id, name, price. In the button template, set the text to {{item.name}} — {{item.price}}, and in Carry set the key product_id with value {{item.id}}. You get one button per product, and when pressed the bot knows exactly which product was chosen.
Per-press parameters (Carry)
The "Carry: data snapshot on button press" block attaches a set of key → value pairs to the button, evaluated and captured at the moment the message is sent. When the button is pressed, these values are restored into ctx: so each button carries its own parameters (per-invocation), even when dozens of buttons were sent in a single message.
- carry key: the name under which the value will be returned to
ctxon press. - carry value: a template with substitutions (
{{item.id}},{{param.order_id}},{{ctx.x}}), evaluated at send time. - One-time (
single_use): the payload is consumed after the first press. - Payload TTL (
ttl_seconds): the lifetime of the snapshot in seconds (0means the default).
This is the core "parameters tied to a specific button" feature: the value is remembered in the button, not in the user's general state, so concurrent presses do not overwrite each other.
Setting parameters via a button (set_params)
In addition to the Carry snapshot, a button can directly set subscriber parameters on press: the "Parameters" field (set_params). Unlike Carry (temporary values in ctx), set_params writes to the user's persistent parameters ({{param.key}}), which are retained between runs. The same field exists on the message block: in that case, parameters are set on send, not on press.
A button press can also set and clear labels: using the same fields as the message block.
Differences between the three mechanisms
- Carry: a snapshot in
ctx, lives until the button is pressed, tied to a specific button, with TTL and one-time use. - set_params on the button: writes persistent subscriber parameters on press.
- set_params on the block: writes persistent parameters when the message is sent.
For the "user chose a product: we ordered it" scenario, use dynamic buttons + Carry: the product list expands into buttons, and each product's product_id is stored in the Carry of exactly that button.
What's next
- Messages and Buttons: message blocks, button types, and on-press behavior.
- Substitutions and Formulas:
{{item.*}},{{ctx.*}},{{param.*}}variables in templates. - Reaction Links: where buttons lead and how to view the transition graph.
- Collections and Data: where to get lists for dynamic buttons.