Condition Check Block
“Condition Check” Block
Section titled ““Condition Check” Block”What is a “Condition Check” Block
Section titled “What is a “Condition Check” Block”The “Condition Check” Block is a powerful conditional branching element in Grailgun that evaluates various aspects of the bot user’s state, including subscription status, user status, and custom variables. This Block allows you to create personalized dialogue flows based on user data and conditions.
Main Functions
Section titled “Main Functions”- Creating conditional branches based on user data
- Checking subscription status and expiration dates
- Validating user status (active, banned, etc.)
- Evaluating custom flow variables (date, number, string types)
- Building complex conditions with AND/OR logic
- Directing dialogue flow based on multiple criteria
Creation and Configuration
Section titled “Creation and Configuration”How to Add a “Condition Check” Block
Section titled “How to Add a “Condition Check” Block”- Open the bot builder
- From the Blocks panel, select “Add Condition”
- The Block will be added to the workspace
Configuring Condition Parameters
Section titled “Configuring Condition Parameters”- Double-click on the “Condition Check” Block in the builder
- Set a title for the Block (optional)
- Build your condition using the visual editor
- Configure condition values and operators
- Click “Save” to apply settings
Condition Types
Section titled “Condition Types”Subscription Date Check (Payed To)
Section titled “Subscription Date Check (Payed To)”Check when the user’s subscription expires:
Available Operators:
- Greater than (>)
- Greater than or equal (≥)
- Less than (<)
- Less than or equal (≤)
- Equal (=)
- Not equal (≠)
Date Types:
- Current Date - Compare against the current time with optional offset in minutes
- Example: “Subscription ends > Current Date + 1440 minutes” (more than 1 day remaining)
- Specific Date - Compare against a specific timestamp in milliseconds
- Example: “Subscription ends < 1704067200000” (before specific date)
Use Cases:
- Check if subscription is expiring soon
- Verify active subscription status
- Send renewal reminders before expiration
User Status Check
Section titled “User Status Check”Check the current status of the bot user:
Available Statuses:
- Active
- Banned
- Inactive
- And other custom statuses configured in your bot
Use Cases:
- Restrict access for banned users
- Provide different content for active vs inactive users
- Handle user lifecycle states
Variable Conditions
Section titled “Variable Conditions”Check custom flow variables created in your bot:
String Variables
Section titled “String Variables”Available Operators:
- Equal (=)
- Not equal (≠)
- Contains
- Does not contain
- Exists / Not exists
Example:
- Variable “user_language” equals “English”
- Variable “user_name” contains “John”
Number Variables
Section titled “Number Variables”Available Operators:
- Greater than (>)
- Greater than or equal (≥)
- Less than (<)
- Less than or equal (≤)
- Equal (=)
- Not equal (≠)
- Exists / Not exists
Example:
- Variable “purchase_count” > 5
- Variable “user_age” ≥ 18
Date Variables
Section titled “Date Variables”Available Operators:
- Greater than (>)
- Greater than or equal (≥)
- Less than (<)
- Less than or equal (≤)
- Equal (=)
- Not equal (≠)
- Exists / Not exists
Date Comparison Types:
- Current Date - Compare against current time with offset in minutes
- Specific Date - Compare against specific timestamp in milliseconds
Example:
- Variable “last_login” < Current Date - 10080 minutes (more than 7 days ago)
- Variable “next_payment” > Current Date (payment is in future)
Building Complex Conditions
Section titled “Building Complex Conditions”Using AND/OR Operators
Section titled “Using AND/OR Operators”Combine multiple conditions using logical operators:
- AND - All conditions must be true
- OR - At least one condition must be true
- Nest conditions to create complex logic trees
Example 1: Premium User Check
(Subscription expires > Current Date)AND(User Status = Active)Example 2: Engagement Check
(Variable "purchase_count" > 0)OR(Variable "referral_count" > 3)Example 3: Complex Access Control
(User Status = Active)AND( (Subscription expires > Current Date) OR (Variable "trial_mode" = "enabled"))Connection Points
Section titled “Connection Points”The Condition Check Block has branching outputs:
- SUCCESS - Connected Block executes when all conditions are met
- ELSE - Connected Block executes when conditions fail
This allows you to route users through different dialogue paths based on their state and data.
Usage Examples
Section titled “Usage Examples”Check Subscription Status
Section titled “Check Subscription Status”Scenario: Provide premium content only to subscribed users
Conditions:
- Subscription expires > Current Date
Result:
- SUCCESS: Show premium content
- ELSE: Prompt to subscribe
Check User Engagement
Section titled “Check User Engagement”Scenario: Reward active users
Conditions:
- Variable “login_count” ≥ 10
- AND
- Variable “last_active” > Current Date - 1440 minutes (within last day)
Result:
- SUCCESS: Send reward
- ELSE: Send re-engagement message
Multi-Tier Access
Section titled “Multi-Tier Access”Scenario: Different content for different user levels
Flow Design:
- First Condition Check: Is premium subscriber?
- SUCCESS: Premium content flow
- ELSE: Next check
- Second Condition Check: Is basic subscriber?
- SUCCESS: Basic content flow
- ELSE: Free content flow
Trial Expiration Warning
Section titled “Trial Expiration Warning”Scenario: Warn users when trial is ending soon
Conditions:
- Subscription expires < Current Date + 4320 minutes (less than 3 days)
- AND
- Subscription expires > Current Date (still active)
- AND
- Variable “warning_sent” ≠ “true”
Result:
- SUCCESS: Send warning and set “warning_sent” variable
- ELSE: Continue normal flow
Tips and Recommendations
Section titled “Tips and Recommendations”- Use clear, descriptive titles for Condition Blocks in complex flows
- Test conditions with different user states to ensure correct behavior
- Combine multiple Condition Blocks for multi-tier decision trees
- Use variable existence checks before comparing values to prevent errors
- Document your condition logic for team members
- Consider edge cases (expired subscriptions, missing variables, etc.)
- Use Variable Change Blocks to set flags when conditions are met
Frequently Asked Questions
Section titled “Frequently Asked Questions”What happens if a variable doesn’t exist?
Section titled “What happens if a variable doesn’t exist?”Use the “Exists / Not exists” operator to check variable existence first, or the Block will take the ELSE path if trying to compare a non-existent variable.
Can I check multiple variables at once?
Section titled “Can I check multiple variables at once?”Yes! Use AND/OR operators to combine multiple variable conditions in a single Condition Check Block.
How do I handle timezone differences in date comparisons?
Section titled “How do I handle timezone differences in date comparisons?”All dates are stored as timestamps in milliseconds (UTC). Use appropriate offsets in minutes when comparing against current date.
What’s the difference between Condition Check and Response Check?
Section titled “What’s the difference between Condition Check and Response Check?”Condition Check evaluates user state and stored data, while Response Check validates incoming user messages. Use Condition Check for user attributes, Response Check for message content.
Can I nest AND/OR operators?
Section titled “Can I nest AND/OR operators?”Yes! The visual editor supports unlimited nesting depth, allowing you to create complex conditional logic trees.