Logic
When a bot receives a message, it will perform 2 tasks
    1.
    Identify what to do
    2.
    Decide how to respond
The platform uses Rules to help your bot identify what to do, and Stories to help your it decide how to respond.

Rule

A test on a message to identify what to do. In its simplest form, 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.

Condition

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: a property, a function, and a value.
For our example above, we can two conditions 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.

Story

A collection of responses returned from the bot. In its simplest form, a story can also be considered a answer from the bot. It can contain one or many text, image, video, audio, document, card, location, 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. First, we 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 . Then, we added a Text Response showing the bank balance with a Refresh Now button. Finally, we added 2 quick replies: How to improve and 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
Last modified 22d ago
Copy link