// Classification Node
{
"url": "http://localhost:8005/api/v1/agents/classifier/invoke",
"jsonBody": "{\"message\": \"Classify this content: {{ $json.content }}\"}"
}
// Switch Node Logic
{
"rules": [
{
"operation": "equal",
"value1": "{{ $node.Classifier.json.result.type }}",
"value2": "blog"
},
{
"operation": "equal",
"value1": "{{ $node.Classifier.json.result.type }}",
"value2": "social"
}
]
}
Quick Start
API Endpoints
POST /api/v1/agents//invoke
Invoke a specific PraisonAI agent with input data. URL Parameters:| Parameter | Type | Description |
|---|---|---|
agent_id | string | The ID/name of the agent to invoke |
| Field | Type | Description |
|---|---|---|
message | string | The input message for the agent |
| Field | Type | Description |
|---|---|---|
session_id | string | Session ID for conversation continuity |
agent_config | object | Override agent configuration |
context | object | Additional context data |
GET /api/v1/agents
List all available agents. Response:GET /api/v1/health
Check API server health status. Response:n8n HTTP Request Configuration
Basic Configuration
- Simple Agent Call
- With Session Management
- With Authentication
Advanced Configuration
Dynamic Agent Selection
Dynamic Agent Selection
Error Handling
Error Handling
Response Processing
Response Processing
Authentication
Token-Based Authentication
Set up authentication for secure API access:- Server Setup
- n8n Configuration
- Environment Variables
API Key Management
Rotation Strategy
Rotation Strategy
Implement token rotation for enhanced security:
Multiple Environments
Multiple Environments
Use different tokens for different environments:
Workflow Examples
Sequential Agent Workflow
- n8n Workflow
- HTTP Node Configuration
- Test Webhook
Create a research → write → publish workflow:
- Webhook Trigger: Receives initial request
- Researcher HTTP Node: Calls
/agents/researcher/invoke - Writer HTTP Node: Calls
/agents/writer/invokewith research data - Publisher HTTP Node: Calls
/agents/publisher/invokewith content - Response Node: Returns final result
Conditional Routing Workflow
Smart Content Router
Smart Content Router
Route content to different agents based on type:
Error Recovery Workflow
Error Recovery Workflow
Implement fallback logic for failed agent calls:
Best Practices
Error Handling
Error Handling
Implement robust error handling in n8n workflows:
Data Validation
Data Validation
Validate data before sending to agents:
Performance Optimization
Performance Optimization
Optimize API calls for better performance:
- Batch Requests: Group multiple agent calls when possible
- Parallel Execution: Use fan-out patterns for independent calls
- Caching: Store frequently used results in Set nodes
- Connection Pooling: Configure HTTP node connection limits
- Timeouts: Set appropriate timeouts based on agent complexity
Security
Security
Secure your API integration:
- Authentication: Always use CALL_SERVER_TOKEN in production
- HTTPS: Use encrypted connections for remote APIs
- Input Sanitization: Validate and sanitize user inputs
- Rate Limiting: Implement rate limiting on the PraisonAI server
- Logging: Enable request logging for audit trails
Troubleshooting
Common Issues
- Connection Errors
- Authentication Errors
- Agent Not Found
Debugging Steps
- Check Server Status: Verify PraisonAI API is running
- Test Endpoints: Use curl to test API endpoints directly
- Validate Credentials: Confirm authentication tokens are correct
- Review Logs: Check both n8n and PraisonAI logs for errors
- Network Connectivity: Ensure n8n can reach PraisonAI server
Related
n8n Integration Overview
Complete guide to n8n integration architecture and setup
n8n Tools Reference
PraisonAI tools for executing n8n workflows from agents
Visual Workflow Editor
Export and edit PraisonAI workflows in n8n’s visual interface
CLI n8n Commands
Command-line tools for n8n workflow management

