Subflows — Reusable Flows
Subflows let you create reusable pieces of logic that you can use multiple times across your bot.
What Is a Subflow?
Think of a subflow as a "mini-flow" that you can call from anywhere:
It's like a recipe you write once and use whenever you need it!
Why Use Subflows?
✅ Don't Repeat Yourself
Instead of copying the same nodes multiple times, create a subflow once and reuse it.
✅ Keep Things Organized
Break complex bots into smaller, manageable pieces.
✅ Easy Updates
Change the subflow once, and it updates everywhere it's used.
Creating a Subflow
Step 1: Open the Functions Panel
Look for "Functions" or "Subflows" in your sidebar or menu.
Step 2: Create New Function
Click "New Function" or "Create Subflow"
Step 3: Define Inputs and Outputs
Inputs — What data does this function need?
- Example:
email(text),user_id(number)
Outputs — What does it return?
- Example:
is_valid(true/false),error_message(text)
Step 4: Build the Flow
Add nodes just like a normal flow. Use the Function Start and Function End nodes.
Subflow Structure
Every subflow has:
Start Node
- Provides the inputs you defined
- Gives access to context (user info, etc.)
End Node
- Collects the outputs
- Returns to wherever the subflow was called
Using a Subflow
Add the "Call Subflow" Node
- Find "Call Subflow" in the sidebar
- Drag it onto your canvas
- Select which subflow to call
- Connect the inputs
Example: Email Validation
The Subflow
Name: validate_email
Input: email (text)
Outputs: is_valid (boolean), error (text)
Using It
Best Practices
1. One Job Per Subflow
Each subflow should do one thing well:
| Good ✅ | Bad ❌ |
|---|---|
validate_email | do_everything |
calculate_discount | process_and_send |
check_subscription | flow1 |
2. Clear Names
Names should explain what the subflow does:
validate_emailcalculate_totalsend_welcome_sequence
3. Document Inputs/Outputs
Make it clear what data goes in and comes out.
Advanced: Subflow Library
BotGami includes a Flow Library with pre-built subflows:
| Template | What It Does |
|---|---|
| Referral System | Tracks who invited whom |
| Email Validator | Checks email format |
| Rate Limiter | Prevents spam |
To use:
- Open Flow Library
- Click Import
- The subflow is added to your project
Tips
Begin with simple subflows (2-3 nodes) and build up complexity as needed.
Subflows share variable scope with the main flow. Variables you set in a subflow are visible outside it.
Next Steps
- Forms & Inputs → — Collect user data
- Keyboards → — Add interactive buttons