{
  "name": "02 · AI Voice Agents / Inbound AI Voice Concierge",
  "active": false,
  "nodes": [
    {
      "id": "e3be199b-ff52-4a0f-8810-185fe806d6b8",
      "name": "📘 Guide",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -640,
        -120
      ],
      "parameters": {
        "content": "## 02 · AI Voice Agents · Inbound AI Voice Concierge\n\n### What this does\nReceives telephony webhook (Twilio/Vonage/Vapi), transcribes speech, runs an AI dialog planner, returns TTS audio URL / next-say payload for the call bridge.\n\n### Setup checklist\n1. Connect STT (Deepgram/Whisper) + TTS (ElevenLabs)\n2. Set telephony webhook to this path\n3. Add knowledge base URL for FAQ lookup\n\n### How to test locally\nPOST `voice-inbound` with `{ \"callId\":\"c1\", \"from\":\"+1...\", \"transcript\":\"I need pricing\" }`\n\n### Tips\n- Keep credentials in n8n Credentials (never hardcode secrets).\n- Use **Test URL** on the Webhook while developing.\n- Activate only after credentials + destinations are configured.\n",
        "width": 560,
        "height": 560,
        "color": 6
      }
    },
    {
      "id": "c2659b6a-859a-4428-8b07-43fccbbb9469",
      "name": "⚙️ Config",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -640,
        480
      ],
      "parameters": {
        "content": "## Config map\n\n- **Webhook path:** `voice-inbound`\n- **Replace** all `https://httpbin.org/...` calls with real integrations.\n- **Credentials:** create in n8n → Credentials, then select on HTTP nodes.\n- **Activate** workflow only after a successful Test execution.\n\n### Local files\nShared host folder is mounted at `/files` inside n8n.",
        "width": 560,
        "height": 320,
        "color": 2
      }
    },
    {
      "id": "de910c79-9571-4695-8b2a-76021ba1f8da",
      "name": "Telephony / Voice Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        220
      ],
      "webhookId": "912c57cc-6208-403c-ba6f-175b7246d6aa",
      "parameters": {
        "httpMethod": "POST",
        "path": "voice-inbound",
        "responseMode": "responseNode",
        "options": {}
      }
    },
    {
      "id": "aa3ea5af-48aa-461e-90a4-79359fbffa00",
      "name": "Normalize Call Event",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        280,
        220
      ],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "callId",
              "value": "={{ ($json.body || $json).callId || $json.body?.CallSid || \"local-call\" }}",
              "type": "string"
            },
            {
              "id": "2",
              "name": "from",
              "value": "={{ ($json.body || $json).from || ($json.body || $json).caller || \"\" }}",
              "type": "string"
            },
            {
              "id": "3",
              "name": "transcript",
              "value": "={{ ($json.body || $json).transcript || ($json.body || $json).text || \"\" }}",
              "type": "string"
            },
            {
              "id": "4",
              "name": "audioUrl",
              "value": "={{ ($json.body || $json).audioUrl || \"\" }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "9dfc269e-fb0d-49e9-93c6-df3fdea1e62e",
      "name": "STT / Intent / Dialog Plan",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        560,
        220
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const e = $input.first().json;\nconst text = (e.transcript || '').toLowerCase();\nlet intent = 'general';\nif (/price|pricing|cost|factura|billing|invoice/.test(text)) intent = 'billing';\nelse if (/book|appointment|demo|schedule/.test(text)) intent = 'booking';\nelse if (/agent|human|representative/.test(text)) intent = 'handoff';\nelse if (/help|support|issue|problem/.test(text)) intent = 'support';\nconst say = {\n  billing: 'I can help with billing. Can I confirm the email on the account?',\n  booking: 'Happy to help schedule. What day works best?',\n  handoff: 'Connecting you to a specialist now.',\n  support: 'Sorry you hit an issue. Briefly tell me what went wrong.',\n  general: 'Thanks for calling. How can I help today?',\n}[intent];\nreturn [{ json: {\n  ...e,\n  intent,\n  language: /[ñáéíóú]|necesito|factura/.test(text) ? 'es' : 'en',\n  replyText: say,\n  ttsHint: 'eleven_multilingual_v2',\n  actions: intent === 'handoff' ? ['transfer'] : ['speak', 'listen'],\n}}];"
      }
    },
    {
      "id": "144f2274-2b45-4bb2-bf13-96628f928989",
      "name": "TTS Provider (replace)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        840,
        100
      ],
      "parameters": {
        "method": "POST",
        "url": "https://httpbin.org/post",
        "options": {},
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}"
      }
    },
    {
      "id": "f73c1b02-bcc0-4a42-929b-6fde6c266edd",
      "name": "CRM / KB Lookup (replace)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        840,
        340
      ],
      "parameters": {
        "method": "POST",
        "url": "https://httpbin.org/post",
        "options": {},
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}"
      }
    },
    {
      "id": "a6667d39-9826-41a3-8036-d5660ea45692",
      "name": "Compose Voice Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1120,
        220
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const parts = $input.all().map(i => i.json);\nconst base = parts[0] || {};\nreturn [{ json: {\n  ok: true,\n  workflow: 'Inbound AI Voice Concierge',\n  callId: base.callId,\n  intent: base.intent,\n  say: base.replyText,\n  actions: base.actions,\n  providerPayloads: parts,\n}}];"
      }
    },
    {
      "id": "b88e9d9b-3818-4e2e-a05e-fbe039b56d3c",
      "name": "Webhook Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1400,
        220
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}",
        "options": {}
      }
    }
  ],
  "connections": {
    "Telephony / Voice Webhook": {
      "main": [
        [
          {
            "node": "Normalize Call Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Call Event": {
      "main": [
        [
          {
            "node": "STT / Intent / Dialog Plan",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "STT / Intent / Dialog Plan": {
      "main": [
        [
          {
            "node": "TTS Provider (replace)",
            "type": "main",
            "index": 0
          },
          {
            "node": "CRM / KB Lookup (replace)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "TTS Provider (replace)": {
      "main": [
        [
          {
            "node": "Compose Voice Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CRM / KB Lookup (replace)": {
      "main": [
        [
          {
            "node": "Compose Voice Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compose Voice Response": {
      "main": [
        [
          {
            "node": "Webhook Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner"
  },
  "tags": [],
  "meta": {
    "templateCredsSetupCompleted": true,
    "description": "Receives telephony webhook (Twilio/Vonage/Vapi), transcribes speech, runs an AI dialog planner, returns TTS audio URL / next-say payload for the call bridge."
  },
  "pinData": {}
}