Now that we've created our passages, we need to direct the conversation flow to them. We'll do that by adding Logic.
Logic is a special type of passage: it doesn't send any message content itself. Logic exists to direct the flow of conversation:
- Regular chatbot passages direct the conversation flow with buttons, Quick Replies, or scripts that lead to specific passages, or with Questions that the chatbot matches against the user's replies.
- Logic passages direct the conversation flow based on conditions, such as whether a variable is set to a specific value.
You can direct the conversation flow to Logic with Questions, buttons, and other Logic, just like a regular passage. When the conversation flow reaches Logic, the chatbot assesses all the defined conditions and performs the appropriate action.
In this guide, we're going to use Logic to send our user to the correct credit card application passage based on the account type variable that was set in the welcome passage:
- Open the Create section of the left-hand navigation.
- Click Conversations.
- Click the Card Application conversation.
- Click the Logic icon to create new Logic in the conversation.
- Rename the Logic to Credit card application triage.
Create the first Logic tab to handle customers with personal accounts:
- In the Logic 1 tab, change the name to Personal account
You don't need to rename the tab, but it makes it easier to understand what your Logic is doing. - Leave the If dropdown to the default setting of all.
We're defining just one condition, so both any and all will work.
If you add more than one condition in a Logic tab, use this setting to define whether all the conditions must be true for Logic to choose this tab, or if any of the conditions must be true. - In the next dropdown, select the AccountType variable you created earlier.
- Leave the middle dropdown set to an equals sign.
- In the last field, type Personal.
Values must match conditions exactly, including capitalisation and spaces. Make sure this matches the value you saved to the variable earlier. - In the Then section, select the personal credit card application passage you created earlier.
Now create a second Logic tab to handle customers with business accounts:
- Click the + at the top of the tab to create a new Logic tab.
Logic tabs are checked from left to right. The chatbot chooses the left-most tab where the conditions match, even if other tabs would also match. - In the new tab, change the name to Business account.
- Leave the If dropdown to the default setting of all.
- In the next dropdown, select the AccountType variable you created earlier.
- Leave the middle dropdown set to an equals sign.
- In the last field, type Business.
Make sure this matches the value you saved to the variable earlier, including capitalisation. - In the Then section, select the business credit card application passage you created earlier.
- In the Else section, leave the default setting of Create New Passage.
The Else section defines what the chatbot should do if none of the Logic tabs match their conditions. In our example, this means what the chatbot will do if the AccountType variable value doesn't match Personal or Business.
We'll handle what the chatbot should do here once we've finished our Logic. - Click Save.
The Logic creates connections to our two credit card application passages. It also created a new passage. This passage was created by the Else section, which we left to the default configuration. In a moment, we'll use that new passage to handle what should happen if our AccountType variable isn't set.
We've created an AccountType variable, and Logic that uses the variable to direct the conversation flow. Now, we need a way to direct the conversation flow to the Logic in the first place. That's our next step: let's add some Questions to our Logic.