Output JSON Schema
Guide to defining structured output formats for Agent Nodes
Output JSON Schema ensures Agent Nodes generate responses in a consistent, structured JSON format. This is crucial for data parsing, conditional routing, and integration with other nodes. However, JSON Schema configuration alone is insufficient; clear prompt instructions are still required for optimal results.
Purpose
Problems Solved:
- Inconsistent AI output that's difficult to parse
- Need for structured data in Condition Nodes
- Integration with APIs or other systems requiring fixed formats
Solution:
- Define JSON schema for agent output
- AI is constrained to follow the specified structure
- Output is always valid JSON according to schema
How to Use
1. Set Output Format in Agent Node
In Agent Node Config Panel:
- Select Output Format → JSON
- Click "Add JSON Schema" or "Edit JSON Schema" button
- JSON Schema Editor will open
2. Define Schema
Two Editor Modes:
Builder Mode
Visual editor with drag-and-drop:
- Click "Add property" for new fields
- Set Name: property name (example:
category,status) - Select Type: STR, NUM, BOOL, ENUM, OBJ, ARR
- Fill Description: explain what AI should generate
Raw Mode
Edit JSON directly for complex schemas.
3. Property Types
String (STR)
{
"name": "message",
"type": "string",
"description": "Summary text from analysis"
}Number (NUM)
{
"score": {
"type": "number",
"description": "Confidence score between 0-100"
}
}Boolean (BOOL)
{
"is_urgent": {
"type": "boolean",
"description": "True if request is urgent"
}
}Enum (ENUM)
{
"category": {
"type": "string",
"enum": ["A", "B", "C"],
"description": "Classification result"
}
}Object (OBJ)
{
"user_data": {
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "number" }
}
}
}Array (ARR)
{
"items": {
"type": "array",
"items": {
"type": "string"
}
}
}Use Case Examples
1. Classification Agent
❌ Schema Only (Insufficient)
Schema:
{
"type": "object",
"properties": {
"category": {
"type": "string",
"enum": ["A", "B", "C"]
}
}
}Prompt:
Classify this request.Problem: AI doesn't understand what categories A, B, C mean. Output may be random or inconsistent.
✅ Schema + Clear Instructions (Optimal)
Schema:
{
"type": "object",
"properties": {
"category": {
"type": "string",
"enum": ["A", "B", "C"],
"description": "Request classification result"
}
},
"required": ["category"]
}Instruction:
You are a precise **Request Classification Agent**. Your SOLE task is to analyze the user's input and categorize it into exactly one of three categories: "A", "B", or "C".
**CLASSIFICATION RULES:**
* **CATEGORY "A" (Information Retrieval)**
* **Goal:** Fetching, reading, or searching for existing data.
* **Triggers:** Search web, get stock price, read local file, list directory contents.
* **CATEGORY "B" (System Operations)**
* **Goal:** Controlling the OS or generating Shell/CLI commands.
* **Triggers:** Shutdown, restart, ping, check IP, make directory (mkdir), git commands.
* **CATEGORY "C" (General & Creative)**
* **Goal:** Everything else.
* **Triggers:** Coding questions, creative writing, translation, general chat, logic puzzles.
**FEW-SHOT EXAMPLES:**
**User:** "Search for today's BBCA stock price."
**Model:** { "category": "A" }
**User:** "Create a terminal command to delete the node_modules folder."
**Model:** { "category": "B" }
**User:** "Explain what a Black Hole is."
**Model:** { "category": "C" }
**User:** "Hello, how are you?"
**Model:** { "category": "C" }Agent Output:
{
"category": "A"
}Use in Condition Node:
input.category == "A"Note: JSON Schema only enforces output format, but doesn't guarantee correct content. Clear instructions with classification rules and few-shot examples ensure the AI understands the task and fills data accurately.
2. Data Extraction Agent
Schema:
{
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Extracted person name"
},
"email": {
"type": "string",
"description": "Extracted email address"
},
"phone": {
"type": "string",
"description": "Extracted phone number"
}
},
"required": ["name"]
}Instruction:
You are a **Contact Information Extraction Agent**. Your task is to extract contact details from the provided text.
**EXTRACTION RULES:**
- Extract full name from the text
- Extract email address if present
- Extract phone number if present
- If information is not found, leave the field empty
**EXAMPLES:**
**User:** "Contact John Doe at john@example.com or call +1234567890"
**Model:** { "name": "John Doe", "email": "john@example.com", "phone": "+1234567890" }
**User:** "My name is Jane Smith, email: jane.smith@company.com"
**Model:** { "name": "Jane Smith", "email": "jane.smith@company.com", "phone": "" }Agent Output:
{
"name": "John Doe",
"email": "john@example.com",
"phone": "+1234567890"
}3. Command Generator Agent
Schema:
{
"type": "object",
"properties": {
"command": {
"type": "string",
"description": "Shell command to execute"
},
"explanation": {
"type": "string",
"description": "What the command does"
}
},
"required": ["command", "explanation"]
}Instruction:
You are a **System Command Generator**. Convert natural language requests into shell commands.
**GENERATION RULES:**
- Generate command for Windows PowerShell or Bash
- Provide clear explanation in the same language as user's request
- Use safe, standard commands
**EXAMPLES:**
**User:** "Check network connection"
**Model:** { "command": "ping google.com", "explanation": "Sends packets to google.com to check network connectivity" }
**User:** "Create folder named 'data_backup'"
**Model:** { "command": "mkdir data_backup", "explanation": "Creates a new folder named 'data_backup' in current directory" }
**User:** "List all files in current directory"
**Model:** { "command": "dir", "explanation": "Lists all files and directories in the current folder" }Agent Output:
{
"command": "ping google.com",
"explanation": "Check network connectivity"
}Use in Call Command Node:
input.command4. Multi-Step Analysis
Schema:
{
"type": "object",
"properties": {
"sentiment": {
"type": "string",
"enum": ["positive", "negative", "neutral"]
},
"score": {
"type": "number",
"description": "Confidence 0-100"
},
"keywords": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": ["sentiment", "score"]
}Instruction:
You are a **Sentiment Analysis Agent**. Analyze the emotional tone of the text.
**ANALYSIS RULES:**
- Classify sentiment as: positive, negative, or neutral
- Provide confidence score between 0-100
- Extract 3-5 key keywords that represent the sentiment
**EXAMPLES:**
**User:** "This product is excellent! Highly satisfied and would recommend."
**Model:** { "sentiment": "positive", "score": 95, "keywords": ["excellent", "satisfied", "recommend"] }
**User:** "The service was okay, nothing special."
**Model:** { "sentiment": "neutral", "score": 60, "keywords": ["okay", "nothing special"] }
**User:** "Very disappointed with the quality and customer support."
**Model:** { "sentiment": "negative", "score": 85, "keywords": ["disappointed", "quality", "support"] }Agent Output:
{
"sentiment": "positive",
"score": 85,
"keywords": ["excellent", "satisfied", "recommend"]
}