Workflow Pipeline
Build an automated classify-then-respond pipeline using the workflow builder. Time: ~20 minutes.
What You Will Build
- A workflow that classifies incoming messages by intent
- Conditional routing to different response agents based on classification
- An automated pipeline: Input → Classify → Route → Respond
- Error handling and fallback paths
What is a Workflow?
A workflow is a directed acyclic graph (DAG) of nodes that process data in sequence or in parallel. Each node can be an agent call, a condition check, a transformation, or an API call. Workflows let you build complex automation without writing code.
Step-by-Step Guide
1
Create Helper Agents
First, create the agents that will be used as nodes in the workflow.
# Classifier Agent - determines intent
curl -X POST http://localhost:8000/api/v1/agents \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "intent-classifier",
"description": "Classifies user messages into categories",
"model": "gpt-4o-mini",
"system_prompt": "Classify the user message into exactly one category: billing, technical, general, or complaint. Respond with only the category name, nothing else.",
"tags": ["workflow", "classifier"]
}'
# Response agents for each category
curl -X POST http://localhost:8000/api/v1/agents \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "billing-responder",
"model": "gpt-4o-mini",
"system_prompt": "You handle billing inquiries. Be helpful with payment, invoice, and subscription questions."
}'
curl -X POST http://localhost:8000/api/v1/agents \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "technical-responder",
"model": "gpt-4o",
"system_prompt": "You handle technical support. Provide detailed troubleshooting steps."
}'
curl -X POST http://localhost:8000/api/v1/agents \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "general-responder",
"model": "gpt-4o-mini",
"system_prompt": "You handle general questions. Be friendly and informative."
}'2
Create the Workflow
Define the workflow structure with nodes and edges.
curl -X POST http://localhost:8000/api/v1/workflows \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "support-pipeline",
"description": "Classify incoming messages and route to the right responder",
"nodes": [
{
"id": "input",
"type": "input",
"config": { "description": "Incoming user message" }
},
{
"id": "classify",
"type": "agent",
"config": { "agent_id": "CLASSIFIER_AGENT_ID" }
},
{
"id": "router",
"type": "condition",
"config": {
"conditions": [
{ "field": "output", "operator": "contains", "value": "billing", "target": "billing" },
{ "field": "output", "operator": "contains", "value": "technical", "target": "technical" },
{ "field": "output", "operator": "contains", "value": "complaint", "target": "escalate" }
],
"default_target": "general"
}
},
{
"id": "billing",
"type": "agent",
"config": { "agent_id": "BILLING_AGENT_ID" }
},
{
"id": "technical",
"type": "agent",
"config": { "agent_id": "TECHNICAL_AGENT_ID" }
},
{
"id": "general",
"type": "agent",
"config": { "agent_id": "GENERAL_AGENT_ID" }
},
{
"id": "escalate",
"type": "webhook",
"config": {
"url": "https://your-ticketing-system.com/api/tickets",
"method": "POST"
}
},
{
"id": "output",
"type": "output",
"config": { "description": "Final response to user" }
}
],
"edges": [
{ "from": "input", "to": "classify" },
{ "from": "classify", "to": "router" },
{ "from": "billing", "to": "output" },
{ "from": "technical", "to": "output" },
{ "from": "general", "to": "output" },
{ "from": "escalate", "to": "output" }
]
}'3
Validate the Workflow
Check that the workflow DAG is valid before running.
curl http://localhost:8000/api/v1/workflows/WORKFLOW_ID/validate \
-H "Authorization: Bearer YOUR_API_KEY"
# Response:
# { "valid": true, "node_count": 8, "edge_count": 6 }4
Execute the Workflow
Run the workflow with a test input.
# Test with a billing question
curl -X POST http://localhost:8000/api/v1/workflows/WORKFLOW_ID/execute \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "input": "I was charged twice on my last invoice" }'
# Test with a technical question
curl -X POST http://localhost:8000/api/v1/workflows/WORKFLOW_ID/execute \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "input": "My API calls are returning 500 errors" }'5
View Execution History
See how the workflow routed each request.
curl http://localhost:8000/api/v1/workflows/WORKFLOW_ID/executions \
-H "Authorization: Bearer YOUR_API_KEY"
# Response shows each execution with:
# - Input message
# - Classification result
# - Which path was taken
# - Final response
# - Total execution timePipeline Visualization
Workflow DAGtext
[Input] --> [Classifier Agent]
|
+-- "billing" --> [Billing Responder] --> [Output]
|
+-- "technical" --> [Technical Responder] --> [Output]
|
+-- "complaint" --> [Webhook: Escalate] --> [Output]
|
+-- (default) --> [General Responder] --> [Output]Using the Dashboard
The Workflows tab provides a visual drag-and-drop builder:
- Navigate to the Workflows tab
- Click Create Workflow
- Drag nodes from the palette: Input, Agent, Condition, Webhook, Output
- Connect nodes by dragging from output ports to input ports
- Configure each node by clicking on it (select agent, set conditions, etc.)
- Click Validate to check the DAG
- Click Execute to run with test input
Advanced Patterns
- Use parallel nodes to run multiple agents simultaneously
- Add transform nodes to reshape data between steps
- Set timeout on each node to prevent hanging
- Use retry configuration for unreliable external APIs