Using Postback

Postback is a mechanism whereby if a user clicks a button, the response is stored in a "payload" which can be read by an item further on in the flow. This can be used to branch the chatbot's flow depending on user response.

The following shows a chatbot example that asks the user whether or not they have an account, and if so, asks for the account number.

Although there is no direct link between Account Query and the two boxes Account Confirmation and No Account Confirmation, there is a logical link that has been created using a Postback button type with a payload.

In the Account Query box, there are two buttons defined: one labelled Yes and one No. In each case the Button Type is Postback. The payload for these buttons is defined as account_yes and account_no respectively. This is why the two boxes labelled Yes and No appear and are linked to the Account Query box. The user will be presented with two buttons, one labelled Yes and No, to click on in response to the question "Do you have an account?" Depending on the user response, the payload is set to either account_yes or account_no.

The Account Confirmation box has account_yes in the box When the User Says, while the No Account Confirmation box has account_no in the box When the User Says. Therefore only one of these boxes will be processed, depending upon the payload set in the Account Query box, and the chatbot flow branches.

Using Conditions

When the user responds to a question, that response can be written to a variable, which can later be tested in a condition to determine what happens next.

The following example achieves the same end as the Postback example above, but using conditions instead of Postback. The only difference is that the user must type their response to the question Do you have an account? (yes or no) rather than clicking a button.

In the Account Query box, under Answers, a variable name of account_status is specified to store the user's response (which should be yes or no). The box Act on Account Status has the following conditions under Settings:

The first condition says that if account_status = yes, then continue with the box called Account Confirmation.

The second condition says that if account_status = no, then continue with the box called No Account Confirmation.