{
  "id": "SixmnXUWppIg1Tbf",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Voice Message Transcription + Intent Classification",
  "tags": [],
  "nodes": [
    {
      "id": "1054438f-1ec7-4eb0-9fbe-6ae413822239",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "0ca12ee3-7651-4a23-8a69-a8ccb963ef6d",
      "name": "Sample Audio (JFK)",
      "type": "n8n-nodes-base.set",
      "position": [
        208,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "cd9f80ef-64b2-4faa-9ebf-2d9b3729ee08",
              "name": "audioUrl",
              "type": "string",
              "value": "https://github.com/openai/whisper/raw/main/tests/jfk.flac"
            },
            {
              "id": "7e5e9364-34c4-424d-b2a5-25b4bae141b5",
              "name": "mimeType",
              "type": "string",
              "value": "audio/flac"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "af3ccc0c-2cad-4969-8177-34be42de7c1a",
      "name": "Download Audio",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        416,
        0
      ],
      "parameters": {
        "url": "={{ $json.audioUrl }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "3a13aa42-7937-42e5-bd35-874227b579a3",
      "name": "Whisper Transcription1",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        624,
        0
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "transcribe"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "ca907376-733c-4918-b685-b95397687adc",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        832,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "3bb22c6d-49d7-4c23-91e5-8a5a5dc42272",
              "name": "=transcript",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e55ba4e6-a5e3-4b2a-9aef-406e10fbc8ea",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -560
      ],
      "parameters": {
        "width": 928,
        "height": 544,
        "content": "## \ud83c\udf99\ufe0f Voice Message Transcription + Intent Classification with OpenAI Whisper\n\nTranscribes audio messages and automatically classifies intent using GPT-4o-mini.\nDemo uses the official OpenAI test audio (JFK speech).\n\n**How to use:**\n1. Add your OpenAI API credentials in Nodes 3 and 5\n2. Replace the audioUrl in Node 1 with your own audio source\n3. Connect to your webhook (Evolution API, Twilio, WhatsApp Cloud API, etc.)\n4. Replace the response nodes with your own logic per intent\n\n**Flow:**\nAudio URL \u2192 Download \u2192 Transcribe (Whisper) \u2192 Classify Intent (GPT-4o-mini) \u2192 Route by Intent\n\n**Intent categories:**\n- `GREETING` \u2014 hello, hi, hey, good morning\n- `QUESTION` \u2014 any question detected\n- `REQUEST` \u2014 specific ask or request\n- `OTHER` \u2014 everything else\n\n**Output:**\n- `transcript` \u2014 plain text transcription\n- `intent` \u2014 classified category in uppercase\n\n**Compatible with:**\nEvolution API \u00b7 Twilio \u00b7 WhatsApp Cloud API \u00b7 Any webhook delivering audio URLs\n\n**Author:** Luis Rend\u00f3n\n\ud83d\udd17 xiaoluxtl.github.io/luis-r"
      },
      "typeVersion": 1
    },
    {
      "id": "cea5fb78-3725-4b65-9748-a61e85a201d8",
      "name": "Extract Intent",
      "type": "n8n-nodes-base.set",
      "position": [
        352,
        256
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "079a9971-4d49-4799-afab-098c1bc6d503",
              "name": "intent",
              "type": "string",
              "value": "={{ $json.output[0].content[0].text.trim().toUpperCase() }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e85c9785-812a-4961-98e4-3f5b37c7306a",
      "name": "Route by Intent",
      "type": "n8n-nodes-base.switch",
      "position": [
        544,
        432
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "greeting",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b1ae04ad-ca42-41fc-a970-0e99b2f1bece",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "GREETING",
                    "rightValue": "={{ $json.intent }}"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "question",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "fa130c67-732e-4dab-bab7-824396846dc2",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "QUESTION",
                    "rightValue": "={{ $json.intent }}"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "request",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "81486d2d-d77f-4f55-9d72-79fd977e8a92",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "REQUEST",
                    "rightValue": "={{ $json.intent }}"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "other",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "7222b25e-bc79-4e20-9ca7-fdace02b92aa",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "OTHER",
                    "rightValue": "={{ $json.intent }}"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "a78155cc-5186-4dcd-891d-62cd5b9f6ab6",
      "name": "Response - Greeting",
      "type": "n8n-nodes-base.set",
      "position": [
        752,
        224
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "0e4606de-3923-4e59-ab9f-b2641372ede7",
              "name": "response",
              "type": "string",
              "value": "\ud83d\udc4b Hello! How can I help you today?"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "57a7f814-6bd4-4e55-8a97-9618523587ed",
      "name": "Response - Question",
      "type": "n8n-nodes-base.set",
      "position": [
        752,
        368
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "0e4606de-3923-4e59-ab9f-b2641372ede7",
              "name": "response",
              "type": "string",
              "value": "\ud83e\udd14 I detected a question. Routing to Q&A handler..."
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "eafc5168-08c3-472d-badd-71951b3922fb",
      "name": "Response - Request",
      "type": "n8n-nodes-base.set",
      "position": [
        752,
        528
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "0e4606de-3923-4e59-ab9f-b2641372ede7",
              "name": "response",
              "type": "string",
              "value": "\ud83d\udccb Request received. Processing your request..."
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e7ab1c5c-c57a-4134-88c4-4f26751507cd",
      "name": "Response - Others",
      "type": "n8n-nodes-base.set",
      "position": [
        752,
        688
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "0e4606de-3923-4e59-ab9f-b2641372ede7",
              "name": "response",
              "type": "string",
              "value": "\ud83d\udcdd Message transcribed and logged successfully."
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "dd65f3ab-a084-4c8f-8c01-a786b3b4dea7",
      "name": "Intent Classifier",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        0,
        256
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {},
        "responses": {
          "values": [
            {
              "content": "=Classify this transcript into exactly one word:\nGREETING, QUESTION, REQUEST, or OTHER.\n\nTranscript: \"{{ $json.transcript }}\"\n\nReply with ONLY the category word, nothing else.\n"
            }
          ]
        },
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "5c70b563-1d98-4035-b4fa-5989ca8ea075",
  "connections": {
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Intent Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Audio": {
      "main": [
        [
          {
            "node": "Whisper Transcription1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Intent": {
      "main": [
        [
          {
            "node": "Route by Intent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Intent": {
      "main": [
        [
          {
            "node": "Response - Greeting",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Response - Question",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Response - Request",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Response - Others",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Intent Classifier": {
      "main": [
        [
          {
            "node": "Extract Intent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sample Audio (JFK)": {
      "main": [
        [
          {
            "node": "Download Audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Whisper Transcription1": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Sample Audio (JFK)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}