Stay in Subworkflow

Hey,
To give you some context, I’ve created three AI agents: a pre-qualification agent, a sales agent, and a customer support agent.
The pre-qualification workflow can route the user to a sub-workflow based on certain conditions. However, the problem is that when the user replies, the conversation always returns to the main workflow instead of continuing inside the sub-workflow.

Do you have any ideas on how to keep the user within the sub-workflow once they’ve been routed there?

I solved this by keeping everything in a single workflow instead of using sub-workflows. The key insight is to persist the routing decision in a table (or use variables if you’re on Cloud).

Here’s how it works:

  1. When a chat message comes in, I first look up the session ID in a data table to check if this user has already been qualified

  2. A Switch node routes the message based on the stored status: sales → Sales Agent, customer → Customer Support Agent, empty → Pre-qualification Agent

  3. The pre-qualification agent has a tool that updates the table with the user’s intent ("sales" or "customer") once it determines where they should go

  4. On subsequent messages, the Switch node automatically routes the user to the correct agent based on the stored value

This approach has a few advantages:

  • Persistent routing: The user stays with the right agent across messages without needing sub-workflow handoffs

  • Shared context: All agents use the same session ID for memory, so the sales agent knows what the user discussed during pre-qualification

  • Easier debugging: You can monitor the entire conversation flow in one place

1 Like

Thank you !