Skip to content

peterzat/n8n-travel-planner-agentic-workflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

n8n-travel-planner-agentic-workflow

πŸ€– Intelligent Travel Planning with Multi-Agent AI Orchestration

An intelligent, self-orchestrating workflow that demonstrates how to build LLM-powered agents using n8n as the orchestration engine. This project showcases task decomposition, specialist routing, and result synthesis - all with minimal code and maximum modularity.

License: MIT n8n OpenAI Python

🎯 What This Workflow Does

The Agentic Travel Planner takes complex user requests and intelligently breaks them down into specialized subtasks, routes each task to the appropriate AI specialist, and synthesizes the results into a comprehensive, actionable plan.

Example Flow:

User Request: "Plan a weekend trip to San Francisco"
        ↓
    [Task Decomposer] 
        ↓
   Activities | Accommodation | Dining | Transportation
        ↓
   [Specialist Agents Process in Parallel]
        ↓
    [Plan Synthesizer]
        ↓
   Complete Weekend Itinerary

πŸ—οΈ Architecture Overview

πŸ“Š Visual Flow Diagram: See workflow-diagram.md for the complete visual representation

Core Components:

  1. 🌐 Webhook Trigger - Receives user requests via HTTP POST
  2. βœ… Input Validation - Ensures proper request format
  3. 🧠 Task Decomposer - OpenAI breaks down complex requests
  4. 🎯 Task Router - Routes subtasks to specialized agents
  5. πŸ€– Specialist Agents - Five specialized OpenAI agents:
    • Activities Agent πŸŽͺ
    • Accommodation Agent 🏨
    • Dining Agent 🍽️
    • Transportation Agent πŸš—
    • General Agent πŸ› οΈ
  6. πŸ“Š Results Collector - Aggregates all specialist responses
  7. 🎼 Plan Synthesizer - Creates cohesive final plan
  8. πŸ“‹ Response Formatter - Structures output with metadata
  9. πŸ“Š Execution Logger - Logs performance and completion stats

πŸ”„ Agent Flow Benefits:

  • Modularity: Each specialist agent has a specific domain of expertise
  • Scalability: Easy to add new specialist agents or modify existing ones
  • Parallel Processing: Multiple agents work simultaneously for faster results
  • Error Handling: Input validation and fallback mechanisms
  • Observability: Comprehensive logging and request tracking
  • Flexibility: Handles diverse request types through intelligent routing

πŸš€ Quick Setup

Prerequisites:

  • n8n instance (cloud or self-hosted)
  • OpenAI API key
  • Basic understanding of n8n workflows

Installation Steps:

  1. Import the Workflow

    # Copy the agentic-workflow.json content
    # In n8n: Workflows β†’ Import from File β†’ Paste JSON
  2. Configure OpenAI Credentials

    # In n8n: Settings β†’ Credentials β†’ Add Credential
    # Type: OpenAI
    # Name: "OpenAI API"
    # API Key: your-openai-api-key
  3. Activate the Workflow

    # In n8n: Toggle the workflow to "Active"
    # Note the webhook URL (usually ends with /travel-agent)

πŸ”§ Configuration Options:

OpenAI Models: Currently set to GPT-4, but can be changed to:

  • gpt-3.5-turbo (faster, cheaper)
  • gpt-4-turbo (more capable)
  • gpt-4o (latest model)

Temperature Settings:

  • Task Decomposer: 0.3 (more deterministic)
  • Specialist Agents: 0.7 (more creative)
  • Plan Synthesizer: 0.5 (balanced)

πŸ“‘ API Usage

Endpoint:

POST https://your-n8n-instance.com/webhook/travel-agent
Content-Type: application/json

Request Format:

{
  "request": "Your planning request here"
}

Response Format:

{
  "success": true,
  "request_id": "unique-request-identifier",
  "original_request": "Plan a weekend trip to San Francisco",
  "plan": "# Complete formatted plan with sections and details",
  "completion_time": "2024-01-01T10:15:30.000Z",
  "tasks_processed": 4
}

Error Response:

{
  "success": false,
  "error": "Invalid request. Please provide a 'request' field in the request body.",
  "example": {
    "request": "Plan a weekend trip to San Francisco"
  }
}

πŸ’‘ Usage Examples

1. Travel Planning

curl -X POST https://your-n8n-webhook-url/travel-agent \
  -H "Content-Type: application/json" \
  -d '{
    "request": "Plan a weekend trip to San Francisco"
  }'

2. Event Planning

curl -X POST https://your-n8n-webhook-url/travel-agent \
  -H "Content-Type: application/json" \
  -d '{
    "request": "Organize a tech conference for 200 people in Austin, Texas"
  }'

3. Date Planning

curl -X POST https://your-n8n-webhook-url/travel-agent \
  -H "Content-Type: application/json" \
  -d '{
    "request": "Help me plan a romantic dinner date in Paris"
  }'

πŸ› οΈ Customization Guide

Adding New Specialist Agents:

  1. Add New Task Type in Task Router:

    {
      "conditions": {
        "string": [
          {
            "value1": "={{$json.task_type}}",
            "value2": "your_new_type"
          }
        ]
      },
      "output": 5
    }
  2. Create New Agent Node:

    {
      "parameters": {
        "resource": "chat",
        "operation": "create",
        "model": "gpt-4",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a [specialty] specialist. [Instructions]"
            }
          ]
        }
      },
      "name": "Your New Agent"
    }
  3. Connect to Results Collector

Modifying Agent Behaviors:

System Prompts: Edit the system role content in each specialist agent Response Format: Modify prompts to request specific output formats (JSON, markdown, etc.) Temperature: Adjust for more/less creative responses

Adding Retry Logic:

{
  "parameters": {
    "conditions": {
      "string": [
        {
          "value1": "={{$json.error}}",
          "operation": "isNotEmpty"
        }
      ]
    }
  },
  "name": "Error Check",
  "type": "n8n-nodes-base.if"
}

πŸ“Š Monitoring & Logging

Built-in Logging:

  • Request ID: Unique identifier for tracking
  • Execution Time: Performance monitoring
  • Task Count: Number of subtasks processed
  • Status Tracking: Request lifecycle monitoring

Log Output Example:

{
  "timestamp": "2024-01-01T10:15:30.000Z",
  "request_id": "1_1704067200000",
  "original_request": "Plan a weekend trip to San Francisco",
  "status": "completed",
  "tasks_processed": 4,
  "execution_time_ms": 15430
}

Adding External Logging:

  1. Database Storage: Add a database node after Execution Logger
  2. Webhook Notifications: Send logs to external monitoring systems
  3. File Storage: Write logs to persistent storage

Diagram Maintenance:

Keep the visual diagram in sync with workflow changes:

# Validate diagram consistency
python update-diagram.py --validate

# Generate workflow summary
python update-diagram.py --summary

πŸ”§ Troubleshooting

Common Issues:

OpenAI API Errors:

  • Check API key validity
  • Verify account credits/usage limits
  • Ensure model access permissions

Webhook Not Responding:

  • Confirm workflow is activated
  • Check webhook URL is correct
  • Verify n8n instance is running

Task Decomposition Failures:

  • Check OpenAI response format
  • Review Task Parser error handling
  • Adjust system prompt clarity

Agent Response Issues:

  • Monitor individual agent responses
  • Adjust temperature settings
  • Refine specialist system prompts

Debug Mode:

Enable debug mode in n8n to see detailed execution logs and intermediate results.

🎯 Advanced Features

1. Memory & Context

Add a memory node to store conversation history:

{
  "parameters": {
    "operation": "create",
    "resource": "item",
    "additionalFields": {
      "memory": "={{$json.conversation_history}}"
    }
  }
}

2. Conditional Routing

Add smart routing based on request complexity:

{
  "parameters": {
    "conditions": {
      "string": [
        {
          "value1": "={{$json.user_request.length}}",
          "operation": "larger",
          "value2": "100"
        }
      ]
    }
  }
}

3. External Tool Integration

Connect real APIs for live data:

{
  "parameters": {
    "url": "https://api.external-service.com/search",
    "method": "GET",
    "qs": {
      "query": "={{$json.search_term}}"
    }
  },
  "name": "External API Call",
  "type": "n8n-nodes-base.httpRequest"
}

πŸš€ Production Considerations

Performance Optimization:

  • Use gpt-3.5-turbo for faster responses when accuracy isn't critical
  • Implement caching for common requests
  • Add request queuing for high-volume usage

Security:

  • Implement API key authentication
  • Add rate limiting
  • Sanitize user inputs
  • Use HTTPS for webhook endpoints

Scalability:

  • Deploy n8n with clustering
  • Use load balancing for webhook endpoints
  • Consider async processing for complex requests

πŸ“š Learning Resources

n8n Documentation:

Agentic AI Concepts:

  • Task Decomposition Strategies
  • Agent Orchestration Patterns
  • LLM Prompt Engineering
  • Multi-Agent System Design

🀝 Contributing

Feel free to extend this workflow with:

  • New specialist agents
  • Enhanced error handling
  • Better logging mechanisms
  • Integration with additional APIs
  • Performance optimizations

πŸ“„ License

This project is open source and available under the MIT License.


πŸ”— GitHub Setup

This project is ready to be pushed to GitHub:

# Create a new repository on GitHub, then:
git remote add origin https://github.com/yourusername/n8n-travel-planner-agentic-workflow.git
git push -u origin main

Repository Features:

  • βœ… Complete project structure with proper .gitignore
  • βœ… MIT License and contribution guidelines
  • βœ… Package.json with npm scripts for testing
  • βœ… Automated diagram validation utilities
  • βœ… Comprehensive documentation and examples

πŸŽ‰ Ready to build your own agentic workflows?

Import the workflow, configure your OpenAI credentials, and start experimenting with intelligent task orchestration!

About

Intelligent travel planning with multi-agent AI orchestration using n8n

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors