To make a sophisticated chatbot, you will want the bot’s conversation to make reference to the answers it has received from the user chatting to it. For example, you might want to ask for the name of the person using the chatbot and then use that name in the conversation from time to time.
The input of the user from earlier in the conversation we term a prior response.
You can utilize the user’s prior responses (and extracted data from the conversation) in a later interaction. This is particularly useful for giving the user a chance to confirm information.
The way to do this is to insert a short command inside of square brackets [ ].
[responseTo interaction=ID fallback=TEXT]
This function takes the response text from an Interaction that you specify by using its ID number. So, for example, [responseTo interaction= 42394] takes the response from the Interaction number 42394. You’ll find the interaction ID list for your current bot at the top right of your Interaction editing window. To quickly insert the correct interaction ID number into your message, just click on the appropriate one from the list.
There is a shortcut button for pasting the correct form for the prior response into your message.
The response data collected will be the whole of the user’s response text.
If the ID is not specified, the function will use the data from the previous interaction by default. If there is no such interaction (e.g. a wrong ID has been used or there was no previous response) fallback TEXT will be used instead. You specify your own word or sentence instead of TEXT, such as ‘Something went wrong. Please, contact our tech support!’
A smart fallback TEXT might be to use a phrase that triggers your Restart Command. The Restart Command is on the Configure page and has START OVER as the default trigger text. So, for example, your response data function might read: [responseTo interaction = 42240 fallback = Oh dear, something has gone wrong, let’s start over].
Interaction ID 1: Hello! What is your name?
Interaction ID 2: Nice to meet you, [responseTo interaction=1 fallback=Something has gone wrong. Let’s start over].
Bot: Hello! What is your name?
Bot: Nice to meet you, Mary.
Alternatively, if the ID is wrong, e.g. [responseTo interaction=2 fallback=Something has gone wrong. Let’s start over], you will get the following:
Bot: Hello! What is your name?
Bot: Nice to meet you, Something has gone wrong. Let’s start over.
Fallback text in the previous interaction appeared since the response for interaction #2 was not available at the time.
If you use a card button to go to the interaction, which contains a response text line [responseTo interaction=ID fallback=TEXT], then you will get the name of the button as a response.
[extractedData interaction=ID fallback=TEXT]]
Using a prior response that was in the form of Extracted Data works in exactly the same way as using text, except that the function always needs a specific interaction ID. There is no default.
You can then use this Extracted Data for collection-type interactions.
Interaction ID 1: Hello! What is your birthday?
Interaction ID 2: Thanks for your response. I will save your birthday — [extractedData interaction=1 fallback=something went wrong, please enter your date of birth in the form mm/dd/yyyy] — to our database.
Bot: Hello! What is your birthday?
Bot: Thanks for your response. I will save your birthday — 01/01/1990 — to our database.
Bot: Thanks for your response. I will save your birthday — something went wrong, please enter your date of birth in the form mm/dd/yyyy. — to our database.
Watch this video tutorial - "With SnatchBot you can easily refer to a user's response in the conversation"
Updated about 1 year ago
Give the possibility to insert custom variable function into the interaction to work with the information your bot has gathered.