Quick steps to execute Workflows externally
Step 1: Design Your Workflow in Agent Studio UI
What You’re Doing: Creating your workflow visually instead of writing complex JSON manually. Why This Matters: The Agent Studio visual builder automatically generates the correct JSON structure for you - no need to understand complex workflow syntax or risk JSON errors. How to Do It:- Open Agent Studio visual workflow builder
- Drag and drop nodes (agents, APIs, conditionals) onto the canvas
- Connect nodes with lines to define the flow
- Configure each node’s parameters in the UI
- CRITICAL: Click on Workflow API
- Copy the entire
workflow_dataJSON structure
Step 2: Execute Your Workflow via run-dag API
What You’re Doing: Taking the JSON from Step 1 and executing it with real data. Why This Matters: This is where your visual workflow becomes a running process that does actual work (processes data, calls APIs, makes decisions). How to Do It:workflow_data: The complete JSON from your visual builder (Step 1)inputs: The actual data you want to process (overrides default values)- Response contains the results from each node in your workflow
Step 3: Monitor Execution with WebSocket Events
What You’re Doing: Getting real-time updates as your workflow runs. Why This Matters: For enterprise use, you need to know immediately when workflows complete, fail, or need attention. Don’t wait for polling - get instant notifications. How to Do It:- Real-time progress updates as each node executes
- Immediate error notifications if something fails
- Final results as soon as the workflow completes
- Ability to update users and trigger other systems instantly
Executing workflow via run-dag Endpoint
What This Is: The core API endpoint that takes your visual workflow and executes it with real data. URL:https://lao.studio.lyzr.ai/run-dag/Method: POST
Purpose: Execute any workflow with real-time monitoring Why You Use This: This is where your designed workflow becomes a running automation that processes data, calls APIs, makes decisions, and produces results.
Request Structure Explained
workflow_data= Your workflow template (same every time)inputs= The specific data for THIS execution (changes each time)
How to Get workflow_data JSON
🎯 Method 1: Agent Studio Visual Builder ⭐ Always Use This What You’re Doing: Getting the perfect JSON without any manual work. Step-by-Step:- Open Agent Studio workflow builder
- Design your workflow visually (drag, drop, connect nodes)
- Click “Export JSON” or “Get API Code” button in the UI
- Copy the ENTIRE
workflow_dataJSON structure - Paste it into your API calls
🔧 Method 2: Workflow Management API (For Existing Workflows) What You’re Doing: Retrieving a workflow you already created and saved.
❌ Method 3: Manual Construction (NEVER Do This) What This Means: Writing the complex JSON structure by hand. Why You Don’t Do This:
- Extremely complex JSON structure with nested dependencies
- Easy to make syntax errors that break execution
- Hard to maintain and debug
- The visual builder does this perfectly for you
Response Structure
Initial Response (Immediate):- Your workflow has been accepted and is now running
- Use the
task_idto track the execution - Connect to WebSocket using your
flow_nameandrun_nameto monitor progress - The workflow continues executing asynchronously
Getting Final Results via Task Status API
What This Is: An alternative way to get workflow results after execution completes, using the task_id from the initial response. When to Use This:- When you can’t use WebSocket connections (firewall restrictions, etc.)
- When you need to retrieve results later (hours/days after execution)
- As a backup method to ensure you capture results
Task Status Endpoint
URL:https://lao.studio.lyzr.ai/task-status/{task_id}Method: GET
Purpose: Retrieve the final results of a completed workflow
Example Request
Response While Processing
Important: This endpoint returnsprocessing status while the workflow is still running. You’ll need to poll periodically or use WebSocket for real-time updates.
Response After Completion
Once the workflow finishes, you get the complete results from all nodes:status: Either “processing” or “completed”results: Object containing output from each node (keyed by node name)- Each node’s complete output data
Polling Pattern Example
When to Use Which Method
| Method | Best For | Pros | Cons |
|---|---|---|---|
| WebSocket | Real-time monitoring | Instant updates, progress tracking | Requires persistent connection |
| Task Status API | Batch processing | Simple HTTP, works everywhere | Requires polling, no progress updates |
WebSocket Events - Real-time Updates
What This Is: A live connection that streams updates as your workflow executes. URL Pattern:wss://lao-socket.studio.lyzr.ai/ws/{flow_name}/{run_name}
Why You Need This: Instead of waiting for the entire workflow to finish, you get instant notifications as each step completes, fails, or progresses. Critical for enterprise applications where users need immediate feedback.
How It Works:
- Start your workflow with run-dag API
- Immediately connect to WebSocket with the same flow_name/run_name
- Receive real-time events as each node executes
- Handle events in your application (update UI, trigger alerts, etc.)
Key Events You Care About
| Event Type | When It Fires | What You Should Do | Why It Matters |
|---|---|---|---|
flow_started | Workflow begins | Update UI: “Processing…” | User knows their request is being handled |
task_started | Node begins execution | Show progress: “Step 1 of 3” | Real-time progress indication |
task_completed | Node finishes | Update progress: “Step 2 of 3” | User sees continuous progress |
flow_completed | Workflow done | Process results, notify user | Handle final results immediately |
task_failed | Node fails | Handle error, maybe retry | Immediate error response, no waiting |
flow_error | Workflow fails | Show error, log for debugging | Critical failure handling |
- Immediate Response: Users see progress instantly, not after 30+ seconds
- Error Handling: Failed steps are caught immediately, not at the end
- Better UX: Real-time progress bars instead of loading spinners
- Monitoring: Operations teams get instant alerts on failures
Real WebSocket Event Examples
Enterprise Customer Support Pipeline
Flow Started:Data Processing Pipeline Events
Flow Started - Data Validation:Production WebSocket Code
Common Node Types
What These Are: The building blocks of your workflows. Each node type does a specific job in your automation pipeline. Important: You configure these visually in Agent Studio - the JSON examples below are just to show you what gets generated.1. Input Node - Define Parameters
What It Does: Defines what data your workflow needs to run (like function parameters). When You Use It: Every workflow needs this to define what data comes in. Example Use Cases: Customer message, file upload, user preferences, priority level2. AI Agent Node - Process with AI
What It Does: Sends data to your AI agent for processing (analysis, generation, decision-making). When You Use It: When you need AI to understand, analyze, or generate content from your data. Example Use Cases: Sentiment analysis, content generation, data extraction, classification3. API Call Node - External Integration
What It Does: Calls your existing systems (CRM, databases, notification services, etc.). When You Use It: When you need to update external systems or get data from them. Example Use Cases: Update Salesforce, send Slack notifications, query databases, call webhooks4. Conditional Node - Smart Routing
What It Does: Uses AI to make decisions about where the workflow should go next. When You Use It: When you need intelligent branching based on content, not just simple if/then rules. Example Use Cases: Route based on sentiment, escalate high-priority issues, approve/reject based on AI analysisEnterprise Integration Patterns
What These Are: Common workflow patterns that solve real business problems. Use these as templates for your own integrations.Pattern 1: Customer Support Automation
Business Problem: Manual customer support is slow, inconsistent, and doesn’t scale. How This Workflow Solves It: Automatically analyzes customer messages, routes to appropriate systems, and provides instant responses.- Customer Query (Input Node): Receives customer message, email, priority
- AI Classification (Agent Node): AI analyzes sentiment, urgency, category
- Route to Agent (Conditional Node): Routes based on complexity/urgency
- Update CRM (API Node): Creates ticket in Salesforce/ServiceNow
- Send Response (API Node): Sends email/Slack notification to customer
- Instant response to customers (not hours later)
- Consistent categorization and routing
- Automatic CRM updates
- Escalation of urgent issues
Pattern 2: Data Processing Pipeline
Business Problem: Manual data validation and processing is error-prone and time-consuming. How This Workflow Solves It: Automated validation, AI-powered analysis, and quality control with human oversight.- Data Input (Input Node): Receives CSV/JSON data files
- Validation (Agent Node): AI checks data quality, format, completeness
- AI Analysis (Agent Node): AI extracts insights, patterns, anomalies
- Quality Check (Conditional Node): Routes based on confidence score
- Export Results (API Node): Saves to database/sends to downstream systems
- Automated data quality control
- Consistent analysis methodology
- Human review only when needed
- Real-time processing status
Pattern 3: Approval Workflow
Business Problem: Manual approval processes are bottlenecks that slow down business operations. How This Workflow Solves It: Automated content generation with human oversight only where required.- Content Generation (Agent Node): AI creates content based on templates/data
- Manager Review (Approval Node): Manager approves/rejects via email/Slack
- Legal Review (Approval Node): Legal team reviews for compliance
- Publish (API Node): Automatically publishes to website/sends to customers
- Faster content creation
- Consistent quality and tone
- Proper approvals maintained
- Audit trail for compliance
Error Handling
Error Response Format
Common Errors & Solutions
| Error | Cause | Solution |
|---|---|---|
TIMEOUT | Node took too long | Retry or increase timeout |
INVALID_CONFIG | Wrong parameters | Check node configuration |
API_RATE_LIMIT | Too many requests | Implement backoff |
AUTH_ERROR | Invalid credentials | Check API keys |
NETWORK_ERROR | Connection issues | Retry with exponential backoff |
💡 Pro Tips
- Use Agent Studio UI: Always design workflows visually first, then export JSON for API use
- Start Simple: Begin with 2-3 node workflows, add complexity gradually
- Test Everything: Use staging environment that mirrors production
- Monitor Early: Set up WebSocket monitoring from day one
- Copy-Paste JSON: Don’t manually write workflow_data - get it from the Studio
- Document Workflows: Keep track of what each workflow does
- Version Control: Treat workflow definitions as code
- Error Recovery: Always plan for failure scenarios
- Performance: Monitor execution times and optimize bottlenecks