BotDistrikt Documentation
  • 🟢Introduction
    • 👋Hello World
    • 🚀Quick Start
    • 🛠️Setup your Account
      • Register for BotDistrikt
      • Forgot Password
      • Chatbots Dashboard
      • Edit Profile
  • 📱Channels
    • Channels Overview
    • Website Chat
      • Website Chat Quick Start
      • Guest Users
    • Facebook Messenger
      • Import Existing Users
      • Facebook Chat Plugin
      • Facebook Checkbox Plugin
      • Facebook Private Replies
      • Facebook Ads Manager
    • Instagram
      • Import Existing Users
      • Instagram Story Mentions
    • Twitter
    • Skype
    • WhatsApp
      • Twilio WhatsApp Integration
    • Telegram
      • Telegram Commands
      • Telegram Groups
      • Telegram Channels
    • SMS
    • Google Assistant
    • WeChat
    • Other Channels
  • 🏆Features
    • Personality
    • Dashboard
    • Forms
    • Rules
      • Conditions
        • Message
        • User Attribute
    • Stories
      • Update Greeting and Fallback from Personality
    • Responses
      • Text
      • Cards
      • Images
      • Videos
      • Audios
      • Documents
      • Webhooks
      • Javascript Functions
    • Sources
      • Websites
      • Documents
      • Google Docs
      • Google Sheets
    • Users
      • Edit Users
      • Delete Users
      • Dear User
    • Inbox
      • Console
      • Messages
      • Reactions
      • Ratings
      • Clicks
      • Broadcast Records
      • Wrong Responses
    • Broadcasts
    • Settings
      • Tags
      • Audit Logs
      • Account
  • ⚙️How BotDistrikt Works
    • Interaction
    • Flow
    • Context
    • Engagement
    • Optimization
    • Artificial Intelligence
  • 🧠Artificial Intelligence
    • OpenAI
    • Vertex AI
    • Wit.ai
    • Dialogflow
      • Connecting to Dialogflow
      • Small Talk Module
        • Importing Responses
      • Multilanguage Support
  • 🧰Business Tools Integrations
    • Webhook
    • Zendesk
    • Chatbase
    • Google Docs
    • Google Sheets
    • Salesforce
  • API Reference
Powered by GitBook
On this page
  • Types of User Context
  • Memory
  • Attribute
  • Functions complementing the attribute
  • Examples

Was this helpful?

  1. Features
  2. Rules

Conditions

A condition is a true/false check on the user’s question.

PreviousRulesNextMessage

Last updated 4 months ago

Was this helpful?

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)

Add a NEW rule with a NEW condition:

CONDITION
type: memory
property: said-hey
function: equals
value: true

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.

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. It checks an EXACT match. Used for direct checks.

"hello" equals "hello" // true
"12345" equals "12345" // true
"goodbye" equals "goodbye" // true
"openai" equals "openai" // true
"2024" equals "2024" // true
"hello" equals "HELLO" // false
"12345" equals "1234" // false
"goodbye" equals "hello" // false
"openai" equals "OpenAI" // false
"2024" equals "2023" // false

does not equal

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

"hello world" matches regex hello(?=\sworld) // true
"hello everyone" matches regex hello(?=\sworld) // false
"hello everyone" matches regex hello(?!\sworld) // true
"hello world" matches regex hello(?!\sworld) // false
"world hello" matches regex (?<=world\s)hello // true
"everyone hello" matches regex (?<=world\s)hello // false
"everyone hello" matches regex (?<!world\s)hello // true
"world hello" matches regex (?<!world\s)hello // false
"I have 2 apples" matches regex \d // true
"I have apples" matches regex \d // false
"hello@world.com" matches regex \S+@\S+\.\S+ // true
"hello world" matches regex \S+@\S+\.\S+ // false
"hello world" matches regex \bworld\b // true
"helloworld" matches regex \bworld\b // false
"12345" matches regex ^\d{5}$ // true
"1234" matches regex ^\d{5}$ // false
"hello world" matches regex \s // true
"helloworld" matches regex \s // false

exists

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

does not have tags

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

does not have exact tag

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

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 to learn more about the properties of tagging.

This is the most powerful check. Knowledge of is required to use this function. Used for pattern-matching checks.

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 section.

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 section.

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 section.

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 section.

🏆
Tags
regular expressions
Tags
Tags
Tags
Tags
User Context options