{
  "name": "02 · AI Voice Agents / Voicemail → Ticket + Summary",
  "active": false,
  "nodes": [
    {
      "id": "a0bbba96-54d3-4ec4-9b00-b4c0043eedca",
      "name": "📘 Guide",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -640,
        -120
      ],
      "parameters": {
        "content": "## 02 · AI Voice Agents · Voicemail → Ticket + Summary\n\n### What this does\nIngests voicemail audio URL, transcribes, summarizes with action items, creates a support ticket, and SMS-acks the caller.\n\n### Setup checklist\n1. STT credential\n2. Helpdesk API (Zendesk/Freshdesk/HTTP)\n3. SMS provider for ack\n\n### How to test locally\nPOST `voice-voicemail` with `{ \"audioUrl\":\"...\", \"caller\":\"+1...\" }`\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": "72c1638b-f85e-4f8d-b73c-3a376772804b",
      "name": "⚙️ Config",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -640,
        480
      ],
      "parameters": {
        "content": "## Config map\n\n- **Webhook path:** `voice-voicemail`\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": "c72bcc45-8779-419b-b098-0c2fb7ff4a85",
      "name": "Telephony / Voice Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        220
      ],
      "webhookId": "6c54c62d-f708-47b1-ab25-2ae17cf1c44a",
      "parameters": {
        "httpMethod": "POST",
        "path": "voice-voicemail",
        "responseMode": "responseNode",
        "options": {}
      }
    },
    {
      "id": "8b4e8f54-9f88-4659-817c-e676f9b125f4",
      "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": "813472b6-f794-4f32-81d3-ee1b0c560ab4",
      "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": "1c7da320-1dbc-4209-b715-f0c3cbef0b98",
      "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": "27afe9fc-c8f5-4c20-9c9d-cdd88b0526c1",
      "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": "5834761a-ded7-497d-92aa-8960b839ff23",
      "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: 'Voicemail → Ticket + Summary',\n  callId: base.callId,\n  intent: base.intent,\n  say: base.replyText,\n  actions: base.actions,\n  providerPayloads: parts,\n}}];"
      }
    },
    {
      "id": "ecad2c3e-ba43-4a39-a80a-7bf3688023d1",
      "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": "Ingests voicemail audio URL, transcribes, summarizes with action items, creates a support ticket, and SMS-acks the caller."
  },
  "pinData": {}
}