AutomationFlowsData & Sheets › AI Customer Service Chatbot

AI Customer Service Chatbot

Original n8n title: Ki Kundenservice Chat

04 - KI Kundenservice Chat. Uses postgres, httpRequest, respondToWebhook. Webhook trigger; 8 nodes.

Webhook trigger★★★★☆ complexity8 nodesPostgresHTTP Request
Data & Sheets Trigger: Webhook Nodes: 8 Complexity: ★★★★☆ Added:

This workflow follows the HTTP Request → Postgres recipe pattern — see all workflows that pair these two integrations.

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": "04 - KI Kundenservice Chat",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "customer-chat",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "Webhook - Chat-Nachricht",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "operation": "select",
        "schema": "public",
        "table": "chat_history",
        "where": "session_id = '{{ $json.sessionId }}' ORDER BY created_at DESC LIMIT 10",
        "options": {}
      },
      "id": "get-chat-history",
      "name": "Supabase - Chat-Verlauf laden",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://api.opencode.ai/v1/chat/completions",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"grok-code\",\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"Du bist der freundliche KI-Kundenservice-Assistent f\u00fcr Simone's Shop. Du hilfst Kunden bei Fragen zu Bestellungen, Produkten, Versand und R\u00fccksendungen. Antworte immer auf Deutsch, freundlich und professionell. Bei komplexen Problemen empfehle den Kontakt zum menschlichen Support. Bestellnummern beginnen mit ORD-.\"\n    },\n    {{ $node['Supabase - Chat-Verlauf laden'].json.map(m => JSON.stringify({role: m.role, content: m.content})).join(',') }},\n    {\n      \"role\": \"user\",\n      \"content\": \"{{ $json.message }}\"\n    }\n  ],\n  \"temperature\": 0.7,\n  \"max_tokens\": 500\n}",
        "options": {}
      },
      "id": "opencode-chat",
      "name": "OpenCode - KI Antwort",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        650,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "insert",
        "schema": "public",
        "table": "chat_history",
        "columns": "session_id, role, content, created_at",
        "additionalFields": {}
      },
      "id": "save-messages",
      "name": "Supabase - Nachrichten speichern",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        850,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const response = $input.first().json;\nconst aiMessage = response.choices[0].message.content;\n\n// Pr\u00fcfen ob Eskalation n\u00f6tig\nconst escalationKeywords = ['beschwerde', 'anwalt', 'r\u00fcckerstattung', 'betrug', 'manager', 'mensch'];\nconst needsEscalation = escalationKeywords.some(kw => \n  $node['Webhook - Chat-Nachricht'].json.message.toLowerCase().includes(kw)\n);\n\nreturn {\n  json: {\n    response: aiMessage,\n    sessionId: $node['Webhook - Chat-Nachricht'].json.sessionId,\n    needsEscalation,\n    timestamp: new Date().toISOString()\n  }\n};"
      },
      "id": "process-response",
      "name": "Antwort verarbeiten",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1050,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.needsEscalation }}",
              "value2": true
            }
          ]
        }
      },
      "id": "if-escalation",
      "name": "Eskalation n\u00f6tig?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1250,
        300
      ]
    },
    {
      "parameters": {
        "url": "={{ $env.CLAWDBOT_WEBHOOK_URL }}/escalation",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "sessionId",
              "value": "={{ $json.sessionId }}"
            },
            {
              "name": "channel",
              "value": "telegram"
            },
            {
              "name": "priority",
              "value": "high"
            }
          ]
        },
        "options": {}
      },
      "id": "escalate",
      "name": "ClawdBot - Eskalation",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        1450,
        200
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ response: $json.response, sessionId: $json.sessionId, escalated: $json.needsEscalation }) }}"
      },
      "id": "respond",
      "name": "Antwort zur\u00fcckgeben",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1650,
        300
      ]
    }
  ],
  "connections": {
    "Webhook - Chat-Nachricht": {
      "main": [
        [
          {
            "node": "Supabase - Chat-Verlauf laden",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase - Chat-Verlauf laden": {
      "main": [
        [
          {
            "node": "OpenCode - KI Antwort",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenCode - KI Antwort": {
      "main": [
        [
          {
            "node": "Supabase - Nachrichten speichern",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase - Nachrichten speichern": {
      "main": [
        [
          {
            "node": "Antwort verarbeiten",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Antwort verarbeiten": {
      "main": [
        [
          {
            "node": "Eskalation n\u00f6tig?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Eskalation n\u00f6tig?": {
      "main": [
        [
          {
            "node": "ClawdBot - Eskalation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Antwort zur\u00fcckgeben",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ClawdBot - Eskalation": {
      "main": [
        [
          {
            "node": "Antwort zur\u00fcckgeben",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    "ai",
    "customer-service",
    "chat"
  ],
  "triggerCount": 0,
  "active": true
}

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

04 - KI Kundenservice Chat. Uses postgres, httpRequest, respondToWebhook. Webhook trigger; 8 nodes.

Source: https://github.com/Delqhi-Projects/opendocs/blob/69e53ca85cefb8b02fde4e6575f6b9499f3a0a42/n8n-workflows/04-ai-customer-chat.json — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

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

Data & Sheets

Scraping. Uses httpRequest, postgres, @apify/n8n-nodes-apify, respondToWebhook. Webhook trigger; 61 nodes.

HTTP Request, Postgres, @Apify/N8N Nodes Apify
Data & Sheets

Workflow B — AI Listing Engine. Uses httpRequest, postgres, errorTrigger. Webhook trigger; 47 nodes.

HTTP Request, Postgres, Error Trigger
Data & Sheets

Fluxo de voluntárias ZendeskXANXBD. Uses functionItem, zendesk, httpRequest, postgres. Webhook trigger; 25 nodes.

Function Item, Zendesk, HTTP Request +1
Data & Sheets

Fluxo de voluntárias ZendeskXANXBD. Uses functionItem, zendesk, httpRequest, postgres. Webhook trigger; 25 nodes.

Function Item, Zendesk, HTTP Request +1
Data & Sheets

Fluxo de voluntárias ZendeskXANXBD. Uses functionItem, zendesk, httpRequest, postgres. Webhook trigger; 25 nodes.

Function Item, Zendesk, HTTP Request +1