Skip to main content

Practical Guide: Creating, Calling, and Debugging Subflows

Learn how to call reusable modules and use the top-toolbar dropdown for lightning-fast independent debugging.

Sophie avatar
Written by Sophie
Updated this week

In our previous guide, we explored the philosophy of modular design. Now, it’s time to get hands-on. Whether you are cleaning up an existing "spaghetti flow" or planning a new complex project from scratch, Octoparse AI provides two powerful ways to implement subflows.

Method 1: Convert Existing Steps (The "Refactor" Approach)

If you have already built a long, linear flow and realized it’s becoming hard to manage, you can "refactor" it instantly without re-doing the work.

Steps:

  1. Select: In the workflow designer, select the sequence of instructions you want to bundle (hold Ctrl + Click to select multiple).

  2. Convert: Right-click the selected block and choose "Convert to Subflow" (or use the shortcut Ctrl+M).

  3. Name: Immediately give it a functional name (e.g., Login_To_System or Extract_Product_Data).

Result: The long list of instructions is replaced by a single, clean Run subflow block. The original steps are now safely tucked away in their own tab.

Method 2: Create from Scratch (The "Architect" Approach)

For complex projects, it’s better to build your "rooms" before you try to live in the house.

Steps:

  1. Create: Go to the Subflow panel (usually on the right) or flow tabs below the tool bar, and click "+" (Create Subflow).

  2. Build: Give it a name and build your logic inside this new, empty subflow tab.

  3. Call: When you are ready to use it in your Main Flow, drag the 【Run subflow】 instruction into the workflow and select your target subflow from the dropdown menu.

The Secret Weapon: Independent Debugging

The greatest advantage of subflows isn't just organization—it’s Speed.

In a linear flow, to test the last 5 steps, you often have to run the first 95 steps. With subflows, you can perform Unit Testing (testing one module at a time):

  • How to locate it: Look at the top toolbar. Next to the primary "Run Main Flow" button, you will see a small downward arrow (▼).

  • How to run it: Click that arrow to expand the dropdown menu, where you will see a list of all your subflows. Simply select the one you want to test, and the robot will execute only that specific module.

  • Why it works: You can verify your "Data Cleaning" logic independently without waiting for the bot to log in and navigate the entire site every single time.

Pro Tip: Since subflows share variables with the Main Flow, remember that if a subflow relies on a variable created earlier (like Product_Price), you should ensure that variable is already defined or has a temporary value before running the subflow alone.

Best Practices for Professional Workflows

To keep your modular system robust, follow these three rules:

  • Single Responsibility Rule: A subflow should do one thing well. Don’t create a subflow called Login and Scrape and Save. Instead, create three separate subflows.

  • Functional Naming: Name your subflows using Action_Object (e.g., Export To CSV, Maps To Profile). Avoid vague names like Part1 or Steps.

  • Standardize with Prefixes: If your project grows large, use prefixes to keep the dropdown menu organized:

    • NAV_ for navigation steps.

    • DATA_ for extraction and cleaning.

    • UTIL_ for utility tasks like logging or file management.

Summary

By mastering the creation and calling of subflows, you move from being a "task-doer" to a Solution Architect. You now have the tools to build automations that are not only powerful but also elegant, readable, and incredibly easy to fix when things change.

Modular design is the final piece of the puzzle in your journey toward intermediate RPA mastery. Happy building!

Did this answer your question?