Buttons in bot replies

Buttons in bot replies

Buttons are used to make it easier for the chatbot user to respond to the bot. You can create buttons for WhatsApp, Facebook Messenger, Telegram, and iMessage. Notify does not support the button feature as of now.

The label of the buttons (button name or label) has a limit of 20 characters, longer labels are cut off. Clicking the button will perform an action, e.g. send a text message to the chat, open a URL, start a call, etc. Please note that the supported actions vary from messenger to messenger.

When creating buttons in the bot builder, 2 fields should be filled in: Button name goes in the left field and Button action – in the right one. If you leave the button action fields empty, the label of your button will be automatically inserted as an action and posted back to the chat when you click the button.

 



Button types

We support the following button actions/types:

  • Text / Postback: outputs the text stored as a button action, just like a manual input.
  • URL: If you set a link as button action, it will be opened on tap (not available in regular buttons in WhatsApp, only in buttons in notifications).
  • Quick reply: Check the box if you want the buttons to appear as quick replies in Facebook. These special buttons disappear again after clicking/tapping.

In Facebook and WhatsApp up to 3 buttons are allowed in one message (but this does not apply to Quick replies in Facebook). If you create more than 3 buttons in the bot builder, they will be automatically split into groups of 3. If you want to use more than 3 buttons, list buttons might be a useful alternative to regular buttons (available in WhatsApp and Apple Business Chat, see the description below).

Here is a summary button-functionalities as supported by different messengers:

Buttons Number List URL Images Multiselect
WhatsApp 3
Facebook 3
Apple Business unlimited
Telegram unlimited
Webchat unlimited
Instagram
Notify
Viber

 

List buttons

WhatsApp and Apple Business Chat offer another feature – the list button. Here it is possible to set up to 10 different answer options for the user to choose from. This not only limits the possible entries, but also saves the end user some typing. In WhatsApp, the user is allowed to select one of the options, in Apple Business Chat, single-choice as well as multiple-choice selections are possible.

Creating an appealing and efficient list is possible within four simple steps:

  • Add a button in your bot reply field
  • Check the “Use List Button” box
  • Add the list name (optional), message content, footer (optional) to the displayed list template
    Now create the buttons: Names of the individual option buttons, Description of the individual buttons (optional), Payload of the individual buttons. If no payload is defined, the name of the button is used.

This is what it might look like in Whatsapp:

 

The list buttons could be used well for the following use cases:

  • product lists
  • different service requests
  • multiple languages
  • book the ideal day for a call
  • … and much more

Special syntax for buttons

Alternatively you can create buttons using the following syntax:

__BUTTONS
__LABEL Your button label
__DESCRIPTION Your button description
__PAYLOAD Your button payload

Don’t forget the double underscores. The description is optional. If you use Notify, which does not support buttons, buttons created via this path will be converted to a textual menu in Notify.



Dynamic buttons

The buttons discussed so far were “static” – they had a fixed label and a specific postback. But what if it is necessary for the button label to dynamically change depending on currently available information, such as displaying different button names depending on variable values stored for the specific user? This is where the so-called “dynamic buttons” come into play.

 

Possible applications for dynamic buttons are:

  • personalize buttons
  • using buttons to access an API interface

First, we need to pick what content we want to end up in the buttons. Then we have several options on how to place the content: either as simple variables in labels/action fiends or a foreach loop with collection/enumeration/ JSON array.

Dynamic buttons with single variables

The simplest way to create dynamic buttons is to display single variables in buttons.

This works very intuitively and is therefore a good way to get started with dynamic buttons. As an example of use, here is a simple bot that collects user data and finally displays a summary to the user. The user has a possibility to choose via buttons which input he/she wants to correct. Since the labels of buttons should contain user-specific information, variables are used in button names. In our example, button payload is static, e.g. trigger “name”, which triggers redirection to the topic “name”:

This is what the finished topic might look like:

In the chat, it looks like this:

 


Dynamic buttons with Foreach loops

Sometimes however neither the contents of the buttons nor the number of buttons is known in advance, e.g. if you get the contents of buttons from variables of type enumeration/collection or an API call. For these cases you could create buttons using the special syntax (see above) in conjunction with foreach loops: here you iterate over the values of variables and output them as buttons.

In our example, there is a variable $group_name$ of type enumeration, for which the predefined business locations are defined as allowed values. The individual business locations are offered to the user as buttons for selection.

 

We created the $group_name$ variable with predefined values:


The following syntax is used to iterate over the values predefined in the $group_name$ variable (access to individual values via the _list_options addition: $group_name_list_options$) and display those in button names:

The empty list button is filled by the foreach loop, so depending on how many values are stored in $group_name$, new buttons are also created. Dynamically adjusting the number of buttons is especially valuable when  the values are returned from an API call where the exact number of elements in the response might be a priory unknown.

In chat it looks like this:

For your use-case take our code snippet and enter your individual variables! Just keep in mind: The button label and the payload must not be longer than 20 characters, the description must not be longer than 72 characters!

__BUTTONS
foreach ($group_name_list_options$)
__LABEL $value$
__PAYLOAD $value$

endforeach