Advanced Flow Concepts
Build complex workflows with conditional branching, tool integration, nested flows, and advanced debugging.
Conditional Branching
Flows can make decisions about which path to take using conditional links.
This enables dynamic, data-driven workflows—where the next step depends on the result of a previous step.
Example: One Conditional Link
Suppose you want to review a document, and if it contains sensitive information, notify compliance; otherwise, archive it.
How it works:
- The check step checks if the user is a VIP.
- If is_vip is True, the flow continues to send_email.
- If not, the flow ends and no email is sent (no result is produced).
Tool Integration:
LLMs in flows can call tools (functions or APIs) as part of their reasoning.
You can link LLM steps to tool steps using is_tool=True
and is_tool_result=True
:
Example: LLM with Weather Tool
Suppose you want your LLM to answer general questions, but if the user asks about the weather, it should call a weather tool to get the latest information.
Key Points:
memory_id
: Enables memory for LLMs. Using the samememory_id
for both LLMs means they share context and conversation history.is_tool
/is_tool_result
: Allows the LLM to call a tool and then use the tool’s result in a follow-up LLM step.- Chaining with memory: The second LLM (llm2) can generate a more informed, context-aware response because it shares memory with the first LLM.
Nesting Flows
You can use a flow as a step inside another flow, enabling modular, reusable workflow components.
Example: Email Processing and Summarization
Suppose you want to process incoming emails by first extracting the main content and then summarizing it with an LLM.
You can define a reusable subflow for the extraction and summarization, and then use it as a step in your main workflow.
StartEvent(..., path='flow', ...)
StartEvent(..., path='flow.get_order', ...)
StartEvent(..., path='flow.validate_order', ...)
OutputEvent(...,path='flow.get_order', ...)
)
StartEvent(..., path='flow.validate_order', ...)
StartEvent(..., path='flow.validate_order.validate', ...)
OutputEvent(..., path='flow.validate_order.validate', ...)
Debugging and Visualization
Use Timbal's built-in tools to visualize and debug your flows.
You can inspect the execution graph, step outputs, and data mappings to understand and optimize your workflow.
For more, see the Flows Overview and Examples.