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


To get a group of buttons, as in the picture above, you need to get an array from the server:
    "Железногорск (Курская область)",
    "Железногорск (Красноярский край)",

Configuring the Component

The path to the array is the name of the variable in which it was transferred. In the example, it's last_request.
If you have an array of objects, you need to tick box "Objects availability inside the array" and specify the value in field "Field name in the data source. It is the text on the button".

Button Processing

Let's say there is an array in User's state:
    {   "id": 1,
       "name": "Button 1"},
    {   "id": 2,
       "name": "Button 2"}
A dynamic group of buttons with hints was sent to the user:
[Button 1]
[Button 2]
The user clicked on button 2 and in variable pressedButton value "Button 2" was written to the state.
You need to get the id (or any other field from the pressed button object).
We will get the necessary field of the array element corresponding to the pressed button using component Assign.
The recording is performed in variable pressedButtonId:
{{#each array}} // Обходим каждый элемент массива
{{#eq ../pressedButton this.name}} // Если текст в pressedButton и this.name совпадают  
{{this.id}} // Записываем требуемое поле

Template for Copy

{{#each array}}{{#eq ../pressedButton this.name}}{{this.id}}{{/eq}}{{/each}}
You can't use such a template if you have identical button names. In case of a match, the fields of all matches will be written in a row.