Flow
Last updated
Last updated
When a bot receives a message, it performs 2 tasks:
Identify what to do
Decide how to respond
The platform uses Rules to help your bot identify what to do, and Stories to help it decide how to respond. When creating a flow, configuring a rule first then a story next helps avoid duplicating stories.
A rule can also be considered a question from a user. When your bot receives a message, it tests the message against all its rules from the top rule (P1) to the bottom rule (PN). The first rule that passes the test is chosen as the Passing Rule.
Let's create a rule called "user is asking bank account balance" in our bot.
Rules are tested in order of appearance. Higher rules have higher priority (P1, P2, etc.), and lower rules have lower priority. Rules can be re-ordered in any way you want them to be tested.
A rule must have one or more conditions.
A boolean expression that returns true or false. When all conditions in a rule are true, the rule becomes the Passing Rule.
A condition tests only one context of a message-receiving interaction, either message, memory, user attributes, or NLP.
Each condition has 3 parts to it:
Property
Function
Value.
For our example above, we include two conditions (C1 and C2) to our rule:
Context
Property
Function
Value
C1
message
text
has keyword
balance
C2
memory
ask-bank-account
equals
true
This is a sample conversation with the rule above
User: My account Bot: Sure, what would you like to know?
Bot uses an action to store a memory property: ask-bank-account, value: true
---------- User: What is my balance?Bot checks its rules and finds the Passing Rule: user is asking bank account balance. Bot has now IDENTIFIED WHAT TO DO
When the Passing Rule is found, the bot replies with the rule's Story.
A collection of responses returned from the bot.
In its simplest form, consider a story an answer from the bot. It may contain one or many text, image, video, audio, document, card, location, and sticker responses. It can also be used to make your bot display buttons for the user to click, and perform certain actions on a context or trigger webhooks.
Let's create a story for the above example called "user is asking about bank balance".
In this story, we created 2 responses and 2 quick replies.
Added a Webhook response to get the user's bank account information from our imaginary custom banking infrastructure, which returns a new memory property bank-balance
.
Added a Text Response displaying the bank balance with a Refresh Now button.
Added 2 quick replies:
How to improve
Contact Customer Support.
The interaction in our example is complete
User: My account Bot: Sure, what would you like to know?
Bot uses an action to store a memory property: ask-bank-account, value: true
---------- User: What is my balance?Bot checks its rules and the Passing Rule: user is asking bank account balance. Bot has now IDENTIFIED WHAT TO DO
----------Bot selects the rule's story to DECIDE HOW TO RESPOND
Bot: Your current balance $536.12