Dynamic buttons with hints

The component sends the user the text and buttons attached to the keyboard, which can be generated from a variable. It works on all platforms.

Appearance of the buttons

Array

To get a group of buttons, as in the picture above, you need to get an array from the server:

[    
  "New York",    
  "Moscow", 
  "Tokio"   
]

The path to the array is the name of the variable in which it was passed. For example, this is Array1, in the Array screen we wrote our array to Array1 variable.

If you get an array from a request, you can specify it as the path to last_request array.

If you have an array of objects, you need to tick Presence of objects inside the array and specify the value in Field Name field in the data source. It is the text on the button.

Let's say we have an array of objects written to Array1 variable:

[ 
 { 
  "id": 1, 
  "name": "button 1"
 }, 
 { 
  "id": 2, 
  "name": "button 2"
 }
]

In Field Name field in the data source enter name value.

In pressedButton variable, we write the text of the button that the user pressed.

Then we write id value to ID variable, which corresponds to the pressed button in Array1 object. To do this, in Assign a variable component, we write the following expression in the value field:

{{#{{#each Array 1}} // Traversing each element of the array
{{#eq ../pressedButton this.name }} // If the text is in pressedButton and this.name match
{{this.id }} // Write down the required field
{{/eq}}{{/each}}

Template for copy

{{#each Array1}}{{#eq ../pressedButton this.name}}{{this.id}}{{/eq}}{{/each}}

Dynamic buttons support rows.

To create a series of dynamic buttons, you need to use a variable that will contain an array of arrays:

[
['Row 1 button 1', 'Row 1 button 2', 'Row 1 button 3'],
['Row 2 button 1', 'Row 2 button 2', 'Row 2 button 3'],
['Row 3 button 1', 'Row 3 button 2', 'Row 3 button 3']
]

Protected content

Dynamic buttons with hints component supports the content protection function in Telegram. With Protect Content checkbox active, the bot user will not be able to copy and forward the information from the message.

To the beginning ↑