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.
Open Bot Builder
Click the Add Node button
Open the Utilities tab
Select IF Statement
Configure the condition settings
Add variables and values
Configure Success and Fail actions
Click Create
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:
Click Add Node
Open the action panel
Click the Utilities tab
The Utilities section contains workflow logic and automation actions.
Selecting IF Statement
Inside the Utilities tab:
Locate the IF Statement action.
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:
Open the Operator dropdown.
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:
Click Add Variable
Search for the required variable
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:
Click Add New Condition
Configure another operator, variable, and value
Repeat as needed
The walkthrough demonstrates adding multiple conditions using the OR operator.
Creating the IF Statement
After configuring all conditions:
Review the condition logic
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:
Drag a Send Text node from the Success output
Enter the action name
Add the success notification message
Click Create
Example:
Bot: ✅ Your payment method has been verified successfully.
Configuring Fail Response
To configure the fail message:
Drag a Send Text node from the Fail output
Enter the action name
Add the fail notification message
Click Create
Example:
Bot: ❌ Invalid payment method selected. Please try again.
Publishing the Bot Changes
After configuring the IF Statement workflow:
Review the Success and Fail paths
Click the Publish button
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