For the complete documentation index, see llms.txt. This page is also available as Markdown.

IF Statement

The IF Statement action allows chatbot builders to create conditional logic workflows inside the bot builder.

This utility action helps the chatbot evaluate conditions and make decisions automatically based on stored customer responses or variables. Depending on whether the condition is successful or fails, different chatbot actions can be triggered.

The walkthrough demonstrates configuring payment validation logic using variables, OR conditions, comparison operators, and automated response actions.

When to Use IF Statement

Use the IF Statement action when the chatbot needs to make decisions based on customer inputs, selections, or stored variables.

Common Use Cases

  • Payment method validation

  • Lead qualification

  • Order status checking

  • Customer segmentation

  • Conditional workflow branching

  • Dynamic chatbot responses

Example Interaction

User: Online Payment Condition Result: Success

The chatbot automatically triggers a success response when the condition matches the configured value.

How to Add IF Statement

Follow these steps to add the IF Statement action to your bot workflow.

  1. Open Bot Builder

  2. Click the Add Node button

  3. Open the Utilities tab

  4. Select IF Statement

  5. Configure the condition settings

  6. Add variables and values

  7. Configure Success and Fail actions

  8. Click Create

  9. Click Publish to deploy the workflow

The walkthrough shows the IF Statement node being added from the Utilities section of the bot builder.

Accessing the Utilities Section

To access the IF Statement action:

  1. Click Add Node

  1. Open the action panel

  2. Click the Utilities tab

The Utilities section contains workflow logic and automation actions.

Selecting IF Statement

Inside the Utilities tab:

  1. Locate the IF Statement action.

  1. Click the action to open the configuration panel.

The walkthrough highlights the IF Statement node used for checking conditions and making workflow decisions.

IF Statement Configuration

When configuring the IF Statement action, several fields must be completed.

Action Name

The Action Name identifies the condition logic inside the workflow.

This name is visible only within the bot builder.

Example

Payment Check Validate Payment Method Order Status Validation

The walkthrough demonstrates renaming the action to:

Payment Check

before saving the configuration.

Condition Type

The Condition Type field defines how multiple conditions should be evaluated.

Available options include:

  • AND

  • OR

The walkthrough specifically selects:

OR

as the logical operator.

OR Condition Logic

When using OR:

  • The condition succeeds if any one condition matches.

Example:

Condition 1 = Online Payment OR Condition 2 = UPI

If either condition matches, the IF Statement returns Success.

Operator

The Operator field defines the comparison method used for validation.

To configure:

  1. Open the Operator dropdown.

  2. Select the required comparison type.

The walkthrough selects:

Is equals to

for comparing the variable value.

Key Field

The Key field contains the variable that should be evaluated.

Before configuring the IF Statement:

The required value must first be stored using another action such as:

  • Payment Collection

  • Ask Actions

  • Assign Variable

The walkthrough specifically notes that the payment value must first be collected and stored before being used in the IF Statement.

Adding Variables

To add a variable:

  1. Click Add Variable

  1. Search for the required variable

  2. Select the variable from the list

The walkthrough demonstrates selecting:

payment

from the variables list.

The selected variable appears as:

{{variables.payment}}

inside the Key field.

Data Type

The Data Type field defines the type of data being validated.

Example types include:

  • Text

  • Number

  • Boolean

The walkthrough uses:

Text

as the selected data type.

Value Field

The Value field contains the expected value for the condition.

Example:

Online Payment

The IF Statement compares the variable value against this configured condition.

Adding Multiple Conditions

To add additional conditions:

  1. Click Add New Condition

  1. Configure another operator, variable, and value

  1. Repeat as needed

The walkthrough demonstrates adding multiple conditions using the OR operator.

Creating the IF Statement

After configuring all conditions:

  1. Review the condition logic

  2. Click the Create button

The IF Statement node will now appear in the workflow.

Workflow Behavior

Once triggered, the IF Statement action:

  • Evaluates variables dynamically

  • Compares values using operators

  • Supports multiple conditions

  • Triggers Success or Fail workflows

  • Enables decision-based chatbot automation

The walkthrough specifically notes:

This is the condition that we have added in the IF statement. Here, you can see the logic that we have defined in the condition.

Success and Fail Actions

After creating the IF Statement:

  • Success output triggers when the condition matches

  • Fail output triggers when the condition does not match

You can connect any chatbot action to either output.

Example:

Success → Send Payment Confirmation Fail → Send Payment Failure Message

The walkthrough demonstrates dragging Send Text nodes for both Success and Fail conditions.

Configuring Success Response

To configure the success message:

  1. Drag a Send Text node from the Success output

  1. Enter the action name

  1. Add the success notification message

  1. Click Create

Example:

Bot: ✅ Your payment method has been verified successfully.

Configuring Fail Response

To configure the fail message:

  1. Drag a Send Text node from the Fail output

  1. Enter the action name

  1. Add the fail notification message

  1. Click Create

Example:

Bot: ❌ Invalid payment method selected. Please try again.

Publishing the Bot Changes

After configuring the IF Statement workflow:

  1. Review the Success and Fail paths

  2. Click the Publish button

  1. Deploy the workflow to production

The final step in the walkthrough demonstrates publishing the configured bot logic successfully.

Example Workflow

Example Chatbot Workflow

Collect Payment Method ↓ IF Statement ↓ Success → Payment Approved Fail → Payment Rejected

Example Interaction

User: Online Payment Condition: {{variables.payment}} = Online Payment Result: Success

The chatbot automatically routes the workflow based on the condition result.

Best Practices

Follow these recommendations when using IF Statement.

Store variables before validation

Ensure customer responses are stored before evaluating conditions.

Use meaningful action names

Clearly identify the purpose of the conditional logic.

Use proper condition operators

Choose AND or OR based on your workflow requirements.

Keep conditions organized

Avoid overly complex condition structures.

Test Success and Fail flows

Verify both outputs behave correctly before publishing.

Summary

The IF Statement action allows chatbot builders to create dynamic conditional workflows inside Ownchat bots.

With IF Statement, you can:

  • Build conditional chatbot logic

  • Validate customer responses dynamically

  • Compare variable values using operators

  • Trigger Success and Fail workflows

  • Automate decision-based chatbot interactions

This utility action helps businesses build smarter chatbot automation and advanced workflow logic within Ownchat.

Last updated