Sometimes you may want your bot to repeat a series of messages. (For example, if your bot is gathering the contact details of five people.)
You can set up looping logic so that your bot repeats the question until your user has provided all of the information they can.
If your bot is generating a document, you can also control how the looped answers will appear in the document.
First, we’ll take you through creating the looping logic in your bot.
Creating looping logic in Flowchart or List view
Here is an example of looping logic:
- (Message A) "Please provide the full name of a defendant." (Full name message)
- (Message B) "Are there more defendants?" (Single choice - text response: Yes or No)
If Message B is answered with Yes, then it can be connected back to Message A for the user to provide another name.
If Message B is answered with No, then you can connect your bot to another message.
Displaying looped responses in your document
Once you’ve created looping logic in your bot, you can display responses to the looped message as a sequence in your document.
For example, if 3 names were given in the example above, the response inserted in the document would look like:
“Name A, Name B and Name C”
To do this, simply insert the response variable where you want it to appear in the document. That’s it!
Looping in a list or table
You may wish to repeat a whole paragraph, row or list item if it contains a response that has been given more than once.
For example, you may wish to list each of the names in the example above as follows:
- Name A
- Name B
- Name C
You can also do this in 3 simple steps:
- In the document editor, focus on the block where you want your response to show up.
- Insert your response(s).
- Click on the “Apply looping” button in the top navigation bar.
The block should appear with pink borders, which tells you looping is applied to that block. This means that the block will appear the same number of times as there are responses to the particular message.
You’re done! Now, test your bot to make sure it works the way you intended it to.