{
  "name": "GhostChat AI Customer Support Bot",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "ghostchat",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "a1b2c3d4-0001-0001-0001-000000000001",
      "name": "Visitor Message",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300],
      "webhookId": "ghostchat-visitor-message"
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "OK",
        "options": {}
      },
      "id": "a1b2c3d4-0002-0002-0002-000000000002",
      "name": "Acknowledge",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [460, 160]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.openai.com/v1/chat/completions",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"gpt-4o-mini\",\n  \"max_tokens\": 300,\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"You are a helpful customer support assistant for this website. Answer visitor questions helpfully and concisely. Keep responses short — 1-3 sentences unless more detail is needed. If you genuinely don't know something, say: I'll have someone follow up with you shortly.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": {{ JSON.stringify($('Visitor Message').item.json.body.content) }}\n    }\n  ]\n}\n\n// To use Claude: change URL to https://api.anthropic.com/v1/messages and add x-api-key header\n// To use Ollama: change URL to http://localhost:11434/api/chat and remove Authorization header",
        "options": {}
      },
      "id": "a1b2c3d4-0003-0003-0003-000000000003",
      "name": "Generate Reply (OpenAI / Claude / Ollama)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [460, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.ghostchat.dev/messages/owner",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"sessionId\": {{ JSON.stringify($('Visitor Message').item.json.body.sessionId) }},\n  \"content\": {{ JSON.stringify($json.choices[0].message.content) }}\n}",
        "options": {}
      },
      "id": "a1b2c3d4-0004-0004-0004-000000000004",
      "name": "Send Reply to Visitor",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [680, 300]
    }
  ],
  "connections": {
    "Visitor Message": {
      "main": [
        [
          { "node": "Acknowledge", "type": "main", "index": 0 },
          { "node": "Generate Reply (OpenAI / Claude / Ollama)", "type": "main", "index": 0 }
        ]
      ]
    },
    "Generate Reply (OpenAI / Claude / Ollama)": {
      "main": [
        [
          { "node": "Send Reply to Visitor", "type": "main", "index": 0 }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": false
  }
}
