n8n Integration

Bidirectional workflow automation between PraisonAI and n8n

n8n integration enables bidirectional workflow automation, connecting PraisonAI agents to n8n’s 400+ integrations including Slack, Gmail, Notion, databases, and APIs.

python
from praisonaiagents import Agent
from praisonai_tools.n8n import n8n_workflow

agent = Agent(
    name="automation-agent",
    instructions="Execute n8n workflows for automation tasks",
    tools=[n8n_workflow],
)
agent.start("Send a Slack message to #general saying Hello!")

The user asks the agent to automate a task; the agent invokes n8n workflows and integrations on their behalf.

Diagram

n8n Integration Architecture

๐Ÿค– PraisonAI Agent

๐Ÿ”ง n8n_workflow tool

๐Ÿ“ก n8n API

โšก n8n Workflow

๐Ÿ“Š 400+ Integrations

๐ŸŒ n8n Trigger

๐Ÿ“ค HTTP Request

๐Ÿ”— PraisonAI API

๐Ÿค– Agent Execution

Quick Start

  1. Install n8n Tools
    bash
    pip install "praisonai-tools[n8n]"
  2. Set Up n8n Instance
    bash
    # Start n8n locally
    docker run -it --rm --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n
    
    # Set environment variables
    export N8N_URL="http://localhost:5678"
    export N8N_API_KEY="<your-n8n-api-key>"  # Optional for local
  3. Use in Agent
    python
    from praisonaiagents import Agent
    from praisonai_tools.n8n import n8n_workflow
    
    agent = Agent(
        name="automation-agent",
        instructions="Execute n8n workflows for automation tasks",
        tools=[n8n_workflow]
    )
    
    agent.start("Send a Slack message to #general saying Hello!")

How It Works

Diagram
Integrationn8n_APIn8n_toolAgentUserIntegrationn8n_APIn8n_toolAgentUser“Send Slack message”Execute workflowPOST /workflows/slack-notify/executeTrigger Slack APIResponseWorkflow resultSuccess/Error“Message sent!”
ComponentPurposeDirection
PraisonAI โ†’ n8nAgents execute workflows via toolsAgent calls n8n
n8n โ†’ PraisonAIWorkflows invoke agents via APIn8n calls Agent
Visual EditorPreview YAML workflows in n8n UIExport/Import

Integration Directions


Common Patterns

Notification Workflows

python
from praisonaiagents import Agent
from praisonai_tools.n8n import n8n_workflow

notification_agent = Agent(
    name="notifier",
    instructions="Send notifications via various channels",
    tools=[n8n_workflow]
)

# Slack notification
notification_agent.start("Send deployment status to #deployments channel")

# Email notification  
notification_agent.start("Email the marketing team about campaign results")

Data Processing

python
from praisonaiagents import Agent
from praisonai_tools.n8n import n8n_workflow

data_agent = Agent(
    name="data-processor",
    instructions="Process data using n8n integrations",
    tools=[n8n_workflow]
)

# Google Sheets integration
data_agent.start("Add this sales data to the Q1 spreadsheet")

# Database operations
data_agent.start("Store customer feedback in PostgreSQL")

Multi-Step Automation

python
from praisonaiagents import Agent, Task, PraisonAIAgents
from praisonai_tools.n8n import n8n_workflow

# Multi-agent workflow with n8n
researcher = Agent(
    name="researcher",
    instructions="Research topics thoroughly",
    tools=[n8n_workflow]
)

publisher = Agent(
    name="publisher", 
    instructions="Publish content to multiple channels",
    tools=[n8n_workflow]
)

# Create coordinated workflow
team = PraisonAIAgents(
    agents=[researcher, publisher],
    process="sequential"
)
team.start("Research AI trends and publish to blog and social media")

Available Integrations

n8n provides 400+ integrations across multiple categories:

Communication & Messaging
  • Chat: Slack, Discord, Microsoft Teams, Telegram, WhatsApp
  • Email: Gmail, Outlook, SendGrid, Mailchimp
  • Video: Zoom, Google Meet, Microsoft Teams
Productivity & Collaboration
  • Documents: Notion, Google Docs, Microsoft Office, Confluence
  • Spreadsheets: Google Sheets, Excel, Airtable
  • Task Management: Trello, Jira, Linear, Asana, Monday.com
Databases & Storage
  • SQL Databases: PostgreSQL, MySQL, SQL Server, Oracle
  • NoSQL: MongoDB, Redis, Elasticsearch, DynamoDB
  • Cloud Storage: Google Drive, Dropbox, AWS S3, Azure Blob
APIs & Development
  • REST APIs: HTTP Request node, GraphQL
  • Webhooks: Trigger and receive webhooks
  • Git: GitHub, GitLab, Bitbucket integration

Best Practices

Error Handling

Always handle workflow errors gracefully in your agent instructions:

python
agent = Agent(
    name="robust-agent",
    instructions="""
    When executing n8n workflows:
    1. Check the result for errors
    2. Retry with different parameters if needed
    3. Provide clear feedback to the user
    4. Log important details for debugging
    """,
    tools=[n8n_workflow]
)
Environment Configuration

Use environment variables for configuration:

bash
# Production setup
export N8N_URL="https://n8n.yourcompany.com"
export N8N_API_KEY="<your-n8n-api-key>"

# Development setup  
export N8N_URL="http://localhost:5678"
# API key optional for local development
Workflow Organization

Create focused, single-purpose workflows in n8n:

  • Good: slack-notify, email-send, database-insert
  • Avoid: do-everything-workflow

This makes workflows more reliable and easier to debug.

Security

Never expose sensitive data in workflow inputs:

python
# Good - use environment variables in n8n
result = n8n_workflow(
    workflow_id="secure-api-call",
    input_data={"endpoint": "https://api.example.com/data"}
)

# Avoid - don't pass API keys directly
# input_data={"api_key": "secret-key"}  # DON'T DO THIS

Related