🤖 Odoo AI Automation with n8n

Complete guide to integrating Odoo with n8n for AI-powered workflows using ChatGPT, OpenAI, and more

May 15, 2025 20 min read AI Automation Advanced

n8n is a powerful open-source workflow automation tool that connects various applications and services. When combined with Odoo and AI services like OpenAI's ChatGPT, you can create intelligent automations that dramatically improve business efficiency.

📋 What You'll Learn:
  • Install and configure n8n on Ubuntu 24.04
  • Connect n8n with Odoo using API credentials
  • Integrate OpenAI/ChatGPT for AI-powered automations
  • Create real-world automation workflows
  • Automate customer support, lead scoring, and document processing

1. Installing n8n on Ubuntu 24.04

Option A: Quick Install with npm (Recommended)

# Install Node.js 20+
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs

# Install n8n globally
sudo npm install n8n -g

# Start n8n
n8n start

Option B: Docker Installation (Production)

# Install Docker
curl -fsSL https://get.docker.com | sudo bash
sudo usermod -aG docker $USER

# Run n8n with Docker
docker run -d --name n8n \
  -p 5678:5678 \
  -v n8n_data:/home/node/.n8n \
  -e N8N_BASIC_AUTH_ACTIVE=true \
  -e N8N_BASIC_AUTH_USER=admin \
  -e N8N_BASIC_AUTH_PASSWORD=your_password \
  n8nio/n8n

Option C: Using PM2 for Production (Recommended)

# Install PM2
sudo npm install pm2 -g

# Start n8n with PM2
pm2 start n8n --name "n8n"
pm2 save
pm2 startup
💡 Pro Tip: For production use, set up n8n as a systemd service for better reliability and automatic restarts.

2. Configuring n8n as a Systemd Service

sudo nano /etc/systemd/system/n8n.service

Add this configuration:

[Unit]
Description=n8n workflow automation
After=network.target

[Service]
Type=simple
User=www-data
ExecStart=/usr/bin/n8n start
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable n8n
sudo systemctl start n8n

3. Configuring Odoo API Access

First, you need to enable API access in Odoo and create API keys.

Step 1: Enable API in Odoo

# In Odoo configuration file
sudo nano /etc/odoo19.conf

Add these lines:

# Enable API
odoo_services = True
xmlrpc_interface = 0.0.0.0
xmlrpc_port = 8069
sudo systemctl restart odoo19

Step 2: Create API Key in Odoo

  1. Log into Odoo as Administrator
  2. Go to Settings → Users & Companies → Users
  3. Select your user → Edit
  4. Go to "API Keys" tab → Create API Key
  5. Copy the generated key

Step 3: Test Odoo API Connection

# Test API with curl
curl -X POST http://localhost:8069/jsonrpc \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "call",
    "params": {
      "service": "common",
      "method": "version",
      "args": []
    },
    "id": 1
  }'

4. Setting Up OpenAI API

# Get your OpenAI API key from https://platform.openai.com/api-keys
export OPENAI_API_KEY="your-api-key-here"

5. Creating AI-Powered Workflows

Workflow 1: AI-Powered Customer Support Ticket Response

🎯 Use Case: Automatically generate intelligent responses to customer support tickets in Odoo using ChatGPT.
{
  "name": "AI Customer Support Auto-Responder",
  "nodes": [
    {
      "name": "Odoo Webhook Trigger",
      "type": "n8n-nodes-base.webhookTrigger",
      "parameters": {
        "path": "odoo-ticket-created",
        "method": "POST"
      }
    },
    {
      "name": "Get Ticket Details",
      "type": "n8n-nodes-base.httpRequest",
      "parameters": {
        "url": "http://localhost:8069/api/tickets/{{$node['Odoo Webhook Trigger'].json.id}}",
        "method": "GET",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth"
      }
    },
    {
      "name": "AI Generate Response",
      "type": "n8n-nodes-base.openAi",
      "parameters": {
        "resource": "chat",
        "model": "gpt-4",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a helpful customer support agent for an Odoo ERP system."
            },
            {
              "role": "user",
              "content": "=Customer ticket: \"{{$node['Get Ticket Details'].json.description}}\"\n\nGenerate a professional, helpful response."
            }
          ]
        }
      }
    },
    {
      "name": "Update Ticket in Odoo",
      "type": "n8n-nodes-base.httpRequest",
      "parameters": {
        "url": "http://localhost:8069/api/tickets/{{$node['Odoo Webhook Trigger'].json.id}}",
        "method": "PUT",
        "body": {
          "response": "={{$node['AI Generate Response'].json.choices[0].message.content}}",
          "status": "responded"
        }
      }
    }
  ]
}

Workflow 2: AI Lead Scoring and Qualification

{
  "name": "AI Lead Scoring",
  "nodes": [
    {
      "name": "New Lead from Odoo CRM",
      "type": "n8n-nodes-base.odooTrigger",
      "parameters": {
        "model": "crm.lead",
        "operation": "create",
        "environment": "production"
      }
    },
    {
      "name": "Analyze Lead with AI",
      "type": "n8n-nodes-base.openAi",
      "parameters": {
        "model": "gpt-3.5-turbo",
        "prompt": "Analyze this lead and provide:\n1. Lead score (1-100)\n2. Priority (High/Medium/Low)\n3. Suggested next action\n\nLead Name: {{$node['New Lead from Odoo CRM'].json.name}}\nCompany: {{$node['New Lead from Odoo CRM'].json.company_name}}\nEmail: {{$node['New Lead from Odoo CRM'].json.email}}\nDescription: {{$node['New Lead from Odoo CRM'].json.description}}\n\nFormat as JSON.",
        "temperature": 0.3
      }
    },
    {
      "name": "Update Lead Score",
      "type": "n8n-nodes-base.odoo",
      "parameters": {
        "model": "crm.lead",
        "operation": "update",
        "recordId": "={{$node['New Lead from Odoo CRM'].json.id}}",
        "fieldsToUpdate": {
          "lead_score": "={{JSON.parse($node['Analyze Lead with AI'].json.choices[0].message.content).lead_score}}",
          "priority": "={{JSON.parse($node['Analyze Lead with AI'].json.choices[0].message.content).priority}}"
        }
      }
    },
    {
      "name": "Send Alert",
      "type": "n8n-nodes-base.emailSend",
      "parameters": {
        "to": "sales-team@yardinc.com",
        "subject": "New High-Value Lead Assigned",
        "text": "A new lead has been qualified as high priority.\n\nLead: {{$node['New Lead from Odoo CRM'].json.name}}\nScore: {{JSON.parse($node['Analyze Lead with AI'].json.choices[0].message.content).lead_score}}\nAction: {{JSON.parse($node['Analyze Lead with AI'].json.choices[0].message.content).suggested_action}}"
      }
    }
  ]
}

Workflow 3: AI-Powered Product Description Generator

{
  "name": "AI Product Description Generator",
  "nodes": [
    {
      "name": "Schedule (Every hour)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "parameters": {
        "rule": {
          "interval": [{
            "field": "hours",
            "hoursInterval": 1
          }]
        }
      }
    },
    {
      "name": "Get Products Without Descriptions",
      "type": "n8n-nodes-base.odoo",
      "parameters": {
        "model": "product.template",
        "operation": "getAll",
        "fields": ["id", "name", "description", "list_price", "categ_id"],
        "filter": [["description", "=", false]],
        "limit": 10
      }
    },
    {
      "name": "Loop Through Products",
      "type": "n8n-nodes-base.splitInBatches",
      "parameters": {
        "batchSize": 1
      }
    },
    {
      "name": "Generate SEO Description",
      "type": "n8n-nodes-base.openAi",
      "parameters": {
        "resource": "chat",
        "model": "gpt-4",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are an expert e-commerce copywriter. Create compelling, SEO-friendly product descriptions."
            },
            {
              "role": "user",
              "content": "Create a product description for:\n\nProduct Name: {{$node['Get Products Without Descriptions'].json.name}}\nCategory: {{$node['Get Products Without Descriptions'].json.categ_id[1]}}\nPrice: ${{$node['Get Products Without Descriptions'].json.list_price}}\n\nInclude:\n- Engaging headline\n- Benefits (3-4 bullet points)\n- SEO keywords\n- Call to action"
            }
          ]
        }
      }
    },
    {
      "name": "Update Product in Odoo",
      "type": "n8n-nodes-base.odoo",
      "parameters": {
        "model": "product.template",
        "operation": "update",
        "recordId": "={{$node['Get Products Without Descriptions'].json.id}}",
        "fieldsToUpdate": {
          "description": "={{$node['Generate SEO Description'].json.choices[0].message.content}}",
          "description_sale": "={{$node['Generate SEO Description'].json.choices[0].message.content}}"
        }
      }
    }
  ]
}

Workflow 4: Smart Invoice Processing with AI

{
  "name": "AI Invoice Processing",
  "nodes": [
    {
      "name": "Email Trigger",
      "type": "n8n-nodes-base.emailTrigger",
      "parameters": {
        "subject": "Invoice"
      }
    },
    {
      "name": "Extract Invoice Data with AI",
      "type": "n8n-nodes-base.openAi",
      "parameters": {
        "model": "gpt-4-vision-preview",
        "prompt": "Extract the following information from this invoice:\n- Invoice Number\n- Vendor Name\n- Total Amount\n- Due Date\n- Line Items\n\nFormat as JSON.",
        "imageUrl": "={{$node['Email Trigger'].json.attachments[0].url}}"
      }
    },
    {
      "name": "Create Invoice in Odoo",
      "type": "n8n-nodes-base.odoo",
      "parameters": {
        "model": "account.move",
        "operation": "create",
        "fieldsToCreate": {
          "move_type": "in_invoice",
          "partner_id": "={{findVendor($node['Extract Invoice Data with AI'].json.vendor_name)}}",
          "invoice_date": "={{$node['Extract Invoice Data with AI'].json.date}}",
          "invoice_line_ids": "={{$node['Extract Invoice Data with AI'].json.line_items}}"
        }
      }
    },
    {
      "name": "Send Approval Request",
      "type": "n8n-nodes-base.emailSend",
      "parameters": {
        "to": "accounting@yardinc.com",
        "subject": "New Invoice Awaiting Approval",
        "text": "An invoice has been processed by AI and is awaiting your review.\n\nInvoice #{{$node['Extract Invoice Data with AI'].json.invoice_number}}\nAmount: ${{$node['Extract Invoice Data with AI'].json.total_amount}}\nVendor: {{$node['Extract Invoice Data with AI'].json.vendor_name}}"
      }
    }
  ]
}

6. Setting Up n8n Credentials

Odoo Credentials

{
  "name": "Odoo Production",
  "type": "odooApi",
  "data": {
    "url": "https://your-odoo-instance.com",
    "username": "your-username",
    "password": "your-password",
    "database": "your-database"
  }
}

OpenAI Credentials

{
  "name": "OpenAI",
  "type": "openAiApi",
  "data": {
    "apiKey": "sk-your-openai-api-key",
    "organization": "your-org-id"
  }
}

7. Securing n8n with Nginx Reverse Proxy

sudo nano /etc/nginx/sites-available/n8n.yourdomain.com
server {
    listen 80;
    server_name n8n.yourdomain.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name n8n.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/n8n.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/n8n.yourdomain.com/privkey.pem;

    location / {
        proxy_pass http://localhost:5678;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        
        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

8. Advanced Automation Examples

🔥 Real-World Examples:
  • Intelligent Email Routing: Use AI to categorize and route customer emails to appropriate Odoo departments
  • Predictive Inventory: Analyze sales patterns and predict reorder points
  • Smart Contract Analysis: Extract key terms from contracts in Odoo Documents
  • Sentiment Analysis: Analyze customer feedback and automatically escalate negative experiences

9. Monitoring and Logging

# Check n8n logs
pm2 logs n8n

# Monitor n8n status
curl http://localhost:5678/healthz

# Enable n8n monitoring
export N8N_METRICS=true
export N8N_METRICS_PORT=5679

10. Cost Optimization Tips

💰 Save Money on AI API Costs:
  • Use GPT-3.5-turbo for simple tasks instead of GPT-4
  • Implement caching for repeated AI queries
  • Set up request throttling to avoid spikes
  • Use batch processing for non-urgent tasks

Troubleshooting Common Issues

⚠️ Common Problems & Solutions:
  • Odoo Connection Failed: Check if Odoo API is enabled and firewall allows port 8069
  • n8n Won't Start: Check if port 5678 is available: sudo netstat -tlnp | grep 5678
  • OpenAI Rate Limits: Implement retry logic with exponential backoff
  • Webhook Issues: Ensure your domain is accessible and SSL is configured

Next Steps

📧 Need Expert Help?

Setting up AI automation for Odoo can be complex. Our team specializes in n8n integration and can help you:

  • Design custom AI workflows for your business
  • Optimize costs and performance
  • Provide ongoing support and maintenance

📱 Contact us on WhatsApp: +44 7735 003407