A condition is a TRUE or FALSE check on the user’s question. A rule has many conditions. The rule’s story is selected as the Passing Rule, and if all the conditions are met, it's Story is returned as the bot's response.
Types of User Context
The user context is the data that is specifically assigned to a Rule. It determines the context of the message that the users might ask.
Message - what a user sends directly to the bot
Memory - what a bot remembers previously about the current chat session
User attribute - what a bot remembers about a user
Natural language Processing (NLP) - what the bot’s NLP engines evaluate a message with.
Memory
At times, a rule does not respond to user's direct message, rather it responds from the interaction history.
Example: If we go to the "hey!" story, we can add an "action" response to make the bot remember this. Let's set the action as follows:
ACTION
type: memory
property: said-hey
funtion: set to
value: true
Now when the bot replies to a user with "hey!", the bot actually set a property called "said-hey" to true on chat's session memory.
CHAT
User: hello there
Bot: hey!
Bot: (secretly, without telling the user, sets *said-hey* to true in the session)
and let's assign this to a new story called "You Just Said Hello"
Now, the chat will go as follows:
CHAT
User: hello there
Bot: hey!
Bot: (secretly, without telling the user, sets *said-hey* to true in the session)
User: how are you?
Bot: (saw that the property said-hey equals true in the user's chat session)
Bot: you just said hello
Attribute
With every User Context chosen, there will be an attribute (text, image, video, etc.).
The first step to implementing a condition is to select an attribute. The next step is to select a condition that complements the attribute.
Functions complementing the attribute
Every attribute comes with complementing functions.
Below will be a list of the the functions that are available as well as examples of the complementing functions that is available when setting conditions.
Function
Description
has keyword
This function checks if the message contains a specific keyword or phrase.
does not have keyword
This checks if a specific keyword or phrase is not present in the message.
equals
This checks if the message exactly matches a specific value or keyword.
does not equal
This checks if the message does not match a specific value or keyword.
matches regex
This checks if the message matches a regular expression pattern.
exists
This checks if a specific property or value exists in the user’s data.
does not exist
This checks if a property or value does not exist in the user’s data.
less than
This checks if a number is less than another value.
greater than
This checks if a number is greater than another value.
has tags
This checks if the user's message has tagged entities.
does not have tags
This checks if the user's message does not have tagged entities.
is exactly
This checks if the message exactly matches a specific keyword, as opposed to containing it.
is not exactly
This checks if the user's message does not exactly match a given keyword or phrase.
has exact tag
This checks if the user's message "is exactly" a tagged entity.
does not have exact tag
This checks if the user's message is not "is exactly" a tagged entity.
is emoji
This checks if the user's message is exactly an emoji.
For has tags, does not have tags, has exact tag, and does not have exact tag it is dependant on the tags created under the Tags Dashboard. You may visit Tags to learn more about the properties of tagging.
Examples
has keyword
"has keyword" is one of the most commonly used functions for the text attribute. It is extremely helpful in FAQs.
'has keyword' is the only function that supports multiple values. (more than 1 keyword)
"What is the cost of shipping" has keyword "shipping" // true
"What are the opening and closing hours of your shop" has keyword "opening,closing" // true
"I need help with my account" has keyword "help,account" // true
"Can I get a refund for my purchase?" has keyword "refund" // true
"Do you offer discounts on bulk orders?" has keyword "discounts,bulk" // true
"What is the cost of shipping" has keyword "payment" // false
"What are the opening and closing hours of your shop" has keyword "pricing" // false
"I need help with my account" has keyword "support" // false
"Can I get a refund for my purchase?" has keyword "exchange" // false
"Do you offer discounts on bulk orders?" has keyword "single" // false
does not have keyword
The opposite of the has keyword function. Checks if a property does not have a keyword from the list of declared keywords.
"What is the cost of shipping" does not have keyword "payment" // true
"What are the opening and closing hours of your shop" does not have keyword "pricing" // true
"I need help with my account" does not have keyword "support" // true
"Can I get a refund for my purchase?" does not have keyword "exchange" // true
"Do you offer discounts on bulk orders?" does not have keyword "single" // true
"What is the cost of shipping" does not have keyword "shipping" // false
"What are the opening and closing hours of your shop" does not have keyword "opening,closing" // false
"I need help with my account" does not have keyword "help,account" // false
"Can I get a refund for my purchase?" does not have keyword "refund" // false
"Do you offer discounts on bulk orders?" does not have keyword "discounts,bulk" // false
equals
Equals function prompts the chatbot to find the exact match of the word input. Itchecks an EXACT match. Used for direct checks.
The opposite of the equals function. Checks if a property does not equal a value
"hello" does not equal "HELLO" // true
"12345" does not equal "1234" // true
"goodbye" does not equal "hello" // true
"openai" does not equal "OpenAI" // true
"2024" does not equal "2023" // true
"hello" does not equal "hello" // false
"12345" does not equal "12345" // false
"goodbye" does not equal "goodbye" // false
"openai" does not equal "openai" // false
"2024" does not equal "2024" // false
matches regex
This is the most powerful check. Knowledge of regular expressions is required to use this function. Used for pattern-matching checks.
Checks that a property exists. Does not require a value. Used for presence checks.
// If a user sends a text message
message[text] exists // true
// If a user clicks a button
message[postback] exists // true
// If a user sends an image
message[image] exists // true
// If a user sends an image with a caption
message[text] exists // true
// If a user sends a video
message[video] exists // true
// If a user sends an audio
message[audio] exists // true
// If a user sends a location
message[location] exists // true
// If a user sends a sticker
message[sticker] exists // true
// If a user has a last name
user[last_name] exists // true
// If a user has a language
user[language_code] exists // true
does not exist
Checks that a property does not exist. opposite of $exists. Does not require a value. Used for negation checks.
// If a user sends a text message
message[text] does not exist // false
// If a user clicks a button
message[postback] does not exist // false
// If a user sends an image
message[image] does not exist // false
// If a user sends an image with a caption
message[text] does not exist // false
// If a user sends a video
message[video] does not exist // false
// If a user sends an audio
message[audio] does not exist // false
// If a user sends a location
message[location] does not exist // false
// If a user sends a sticker
message[sticker] does not exist // false
// If a user has a last name
user[last_name] does not exist // false
// If a user has a language
user[language_code] does not exist // false
less than
Checks that a numeric property is less than the value. Used for number comparison checks.
"5" less than 10 // true
"3" less than 7 // true
"2" less than 5 // true
"15" less than 20 // true
"8" less than 9 // true
"5" less than 3 // false
"10" less than 5 // false
"7" less than 2 // false
"20" less than 15 // false
"9" less than 8 // false
greater than
Checks that a numeric property is greater than the value. Used for number comparison checks.
"10" greater than 5 // true
"7" greater than 3 // true
"5" greater than 2 // true
"20" greater than 15 // true
"9" greater than 8 // true
"3" greater than 5 // false
"5" greater than 10 // false
"2" greater than 7 // false
"15" greater than 20 // false
"8" greater than 9 // false
has tags
This checks if the user's message has tagged entities. For a deeper understanding of how tags work, including examples and their use cases, refer to the Tags section.
does not have tags
This checks if the user's message does not have tagged entities. For a deeper understanding of how tags work, including examples and their use cases, refer to the Tags section.
is exactly
This checks if the message exactly matches a specific keyword, as opposed to containing it.
"cancel my order" is exactly "cancel my order" // true
"cancel subscription" is exactly "cancel subscription" // true
"update my account" is exactly "update my account" // true
"track my order" is exactly "track my order" // true
"order status" is exactly "order status" // true
"cancel my order" is exactly "cancel subscription" // false
"cancel subscription" is exactly "update my account" // false
"update my account" is exactly "track my order" // false
"track my order" is exactly "order status" // false
"order status" is exactly "cancel my order" // false
is not exactly
This checks if the user's message does not exactly match a given keyword or phrase.
"cancel my order" is not exactly "cancel subscription" // true
"cancel subscription" is not exactly "update my account" // true
"update my account" is not exactly "track my order" // true
"track my order" is not exactly "order status" // true
"order status" is not exactly "cancel my order" // true
"cancel my order" is not exactly "cancel my order" // false
"cancel subscription" is not exactly "cancel subscription" // false
"update my account" is not exactly "update my account" // false
"track my order" is not exactly "track my order" // false
"order status" is not exactly "order status" // false
has exact tag
This checks if the user's message is exactly a tagged entity. For a deeper understanding of how tags work, including examples and their use cases, refer to the Tags section.
does not have exact tag
This checks if the user's message is not exactly a tagged entity. For a deeper understanding of how tags work, including examples and their use cases, refer to the Tags section.
is emoji
This checks if the user's message is exactly an emoji (no text, just an emoji).
"🙂" is emoji // true
"😄" is emoji // true
"😊" is emoji // true
"💬" is emoji // true
"👍" is emoji // true
"Hello" is emoji // false
"Order status" is emoji // false
"Can you help me?" is emoji // false
"What time is it?" is emoji // false
"Cancel my order" is emoji // false