AutomationFlowsAI & RAG › Webhook Command Processor with Postgres

Webhook Command Processor with Postgres

Original n8n title: Command Processing Workflow

Command Processing Workflow. Uses postgres. Webhook trigger; 4 nodes.

Webhook trigger★★★★☆ complexity4 nodesPostgres
AI & RAG Trigger: Webhook Nodes: 4 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "Command Processing Workflow",
  "nodes": [
    {
      "parameters": {
        "path": "webhook/command",
        "responseMode": "responseNode",
        "options": {}
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "// Get input data\nconst input = $input.first();\n\n// Extract command details\nconst {\n  activityId,\n  command,\n  hasAttachments,\n  attachments,\n  user,\n  timestamp\n} = input.json;\n\n// Simple routing logic based on command content\nlet routedAgent = {\n  id: 'chat-gpt',\n  name: 'Chat GPT'\n};\n\nif (command.toLowerCase().includes('calendar') || command.toLowerCase().includes('schedule')) {\n  routedAgent = {\n    id: 'calendar',\n    name: 'Calendar'\n  };\n} else if (command.toLowerCase().includes('email') || command.toLowerCase().includes('mail')) {\n  routedAgent = {\n    id: 'email',\n    name: 'Email'\n  };\n} else if (command.toLowerCase().includes('home') || command.toLowerCase().includes('light')) {\n  routedAgent = {\n    id: 'home-assistant',\n    name: 'Home Assistant'\n  };\n}\n\n// Return routing result\nreturn {\n  json: {\n    activityId,\n    routedAgent,\n    message: `Your request has been routed to ${routedAgent.name}`,\n    timestamp: new Date().toISOString()\n  }\n};"
      },
      "name": "Route Command",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "operation": "update",
        "table": "activities",
        "where": {
          "id": "={{$json.activityId}}"
        },
        "set": {
          "agent": "={{$json.routedAgent.name}}",
          "agent_id": "={{$json.routedAgent.id}}",
          "status": "completed",
          "detailed_content": "={{$json.message}}",
          "updated_at": "={{$json.timestamp}}"
        }
      },
      "name": "Update Supabase",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        650,
        300
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        850,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Route Command",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Command": {
      "main": [
        [
          {
            "node": "Update Supabase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Supabase": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Command Processing Workflow. Uses postgres. Webhook trigger; 4 nodes.

Source: https://github.com/TungNguyenNTT/personal-ai-agents-april-01/blob/6c72ed9d7a19e47edb9301ee10e4895b4c95469f/n8n-workflows/command-workflow.json — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This template is for developers, teams, and automation enthusiasts who want a private, PIN-protected Telegram chatbot that answers questions from their own documents — without relying on external AI A

Postgres, Telegram, HTTP Request +2
AI & RAG

HVAC Event Generator v1.0 - INSERT OPERATIONS. Uses postgres. Webhook trigger; 16 nodes.

Postgres
AI & RAG

Eu Clara – Funil Kiwify Completo. Uses postgres, openAi, httpRequest, gmail. Webhook trigger; 70 nodes.

Postgres, OpenAI, HTTP Request +1
AI & RAG

Lua Nova - Sistema Completo. Uses postgres, httpRequest, openAi. Webhook trigger; 55 nodes.

Postgres, HTTP Request, OpenAI
AI & RAG

User Signup & Verification: The workflow starts when a user signs up. It generates a verification code and sends it via SMS using Twilio. Code Validation: The user replies with the code. The workflow

Postgres, HTTP Request, OpenAI +2