Skip to main content

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

  1. Find "Call Subflow" in the sidebar
  2. Drag it onto your canvas
  3. Select which subflow to call
  4. 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_emaildo_everything
calculate_discountprocess_and_send
check_subscriptionflow1

2. Clear Names

Names should explain what the subflow does:

  • validate_email
  • calculate_total
  • send_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:

TemplateWhat It Does
Referral SystemTracks who invited whom
Email ValidatorChecks email format
Rate LimiterPrevents spam

To use:

  1. Open Flow Library
  2. Click Import
  3. The subflow is added to your project

Tips

Start Small

Begin with simple subflows (2-3 nodes) and build up complexity as needed.

Variables

Subflows share variable scope with the main flow. Variables you set in a subflow are visible outside it.


Next Steps