Skip to content

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.

  • 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
  1. Open the bot builder
  2. From the Blocks panel, select “Add Condition”
  3. The Block will be added to the workspace
  1. Double-click on the “Condition Check” Block in the builder
  2. Set a title for the Block (optional)
  3. Build your condition using the visual editor
  4. Configure condition values and operators
  5. Click “Save” to apply settings

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

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

Check custom flow variables created in your bot:

Available Operators:

  • Equal (=)
  • Not equal (≠)
  • Contains
  • Does not contain
  • Exists / Not exists

Example:

  • Variable “user_language” equals “English”
  • Variable “user_name” contains “John”

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

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)

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 &gt; Current Date)
AND
(User Status = Active)

Example 2: Engagement Check

(Variable "purchase_count" &gt; 0)
OR
(Variable "referral_count" &gt; 3)

Example 3: Complex Access Control

(User Status = Active)
AND
(
(Subscription expires &gt; Current Date)
OR
(Variable "trial_mode" = "enabled")
)

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.

Scenario: Provide premium content only to subscribed users

Conditions:

  • Subscription expires > Current Date

Result:

  • SUCCESS: Show premium content
  • ELSE: Prompt to subscribe

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

Scenario: Different content for different user levels

Flow Design:

  1. First Condition Check: Is premium subscriber?
    • SUCCESS: Premium content flow
    • ELSE: Next check
  2. Second Condition Check: Is basic subscriber?
    • SUCCESS: Basic content flow
    • ELSE: Free content flow

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
  • 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

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.

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.

Yes! The visual editor supports unlimited nesting depth, allowing you to create complex conditional logic trees.