Skip to main content
This page requires Python familiarity for the programmatic examples. Non-technical operators can trigger flows from Managed Topics actions without writing code – see Start a flow from a Managed Topics action below. All code-focused content is also available in the Developer tab.
A flow starts when something calls conv.goto_flow("Flow name"). This may happen through a Managed Topics action or programmatically inside a function. This page explains how conv.goto_flow can be used: You can call conv.goto_flow(...) from any function in Agent Studio, including: Example:
def start_booking(conv: Conversation):
    conv.goto_flow("Make a booking")
    return
What happens:
  • The function runs during the current turn.
  • When the turn completes, the agent enters the named flow.
  • The flow begins at its configured start step.

Start a flow from a Managed Topics action

A Managed Topic can trigger a flow when it matches a user request. This is the primary way to collect entities from a topic, since Managed Topics do not support entity extraction directly.

Using the /Flow shortcut (no code)

example-main Inside a Managed Topics Actions field, type /Flow and use the (+) option to create or attach a flow. When the topic matches, the agent enters the selected flow at its start step. No custom function is required if you just need to enter the flow.

Using a tool call from a topic

If you need additional logic before entering the flow – for example, storing context so the agent can return to the topic afterward – use a tool call action instead:
def start_verification_flow(conv: Conversation, original_faq: str):
    """
    Enter the verification flow and remember which topic we came from.
    Args:
        original_faq: the name of the topic that triggered this function
    """
    conv.state.original_topic = original_faq
    conv.goto_flow("Verify Identity")
    return
You can also trigger a flow from a global function by calling conv.goto_flow() directly.

Returning to a topic after a flow

When a topic triggers a flow (e.g. to collect a date or verify identity), the agent can return to the original topic content after the flow exits. To do this:
  1. Before entering the flow, store the topic name in state (e.g. conv.state.original_topic).
  2. In the flow’s exit function, check the stored topic and return a prompt that directs the LLM to the relevant topic content:
def exit_and_resume(conv: Conversation, flow: Flow):
    conv.exit_flow()
    if conv.state.original_topic:
        return {
            "content": f"Look for the topic '{conv.state.original_topic}' in your context. "
                       f"Continue answering the caller's original question."
        }
    return {"utterance": "Is there anything else I can help with?"}
This pattern avoids a generic “Is there anything else?” when the caller’s original question has not yet been answered.

Start or switch flows from inside another flow

Once a user is inside a flow, most movement should happen using flow.goto_step(...). That keeps the user inside the same workflow and simply branches to another step. However, sometimes you need to switch to an entirely different workflow. Examples:
  • The user fails identity verification and must enter a verification flow.
  • The user requests a human agent and must enter an escalation flow.
  • A compliance rule requires a separate structured process.
  • The user changes intent entirely (e.g., from booking to cancellation).
In these cases, start a new flow instead of branching. You do this by calling conv.goto_flow("Flow name") from a function inside the current flow.

Example: Escalating after repeated failed verification

Imagine a booking flow where the user must confirm their date of birth. If they fail verification too many times, you want to move them into a dedicated verification flow.
def check_verification(conv: Conversation, flow: Flow):
    attempts = conv.state.verification_attempts or 0

    if not conv.state.is_verified:
        attempts += 1
        conv.state.verification_attempts = attempts

        if attempts >= 3:
            conv.goto_flow("Identity Verification")
            return

        flow.goto_step("Retry verification")
        return

    flow.goto_step("Continue booking")
    return
Inside a function, only the last flow.goto_step(...) call is executed

Routing based on API results

Main article: conv.api A function may call an API using conv.api. After receiving a response, explicitly choose one of two actions:
  • Stay in the current workflow using flow.goto_step(...)
  • Switch workflows using conv.goto_flow(...)
Example:
def check_customer_status(conv: Conversation, flow: Flow):
    response = conv.api.crm.lookup_user(id=conv.state.user_id)

    if response.status_code != 200:
        flow.goto_step("API error handling")
        return

    data = response.json()

    if data.get("status") == "requires_verification":
        conv.goto_flow("Verification flow")
        return

    flow.goto_step("Continue booking")
    return

Next steps

Flows overview

Understand how flows work and the available trigger methods.

Transition functions

Control routing logic with Python inside flow steps.

Flow object

Python reference for goto_step() and current_step.
Last modified on April 20, 2026