{
  "name": "Whisper Transcription v1.1",
  "active": true,
  "isArchived": false,
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "transcribe",
        "responseMode": "lastNode",
        "responseData": "allEntries",
        "options": {
          "rawBody": true
        }
      },
      "id": "91945dd9-42f8-4343-b131-9e46272f04bf",
      "name": "Transcription Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [0, 0],
      "webhookId": "f50eec94-1e56-4189-88ee-51b701c1d889"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://10.5.30.7:8786/v1/audio/transcriptions",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "file",
              "inputDataFieldName": "data"
            },
            {
              "name": "model",
              "value": "Systran/faster-distil-whisper-small.en"
            },
            {
              "name": "language",
              "value": "en"
            },
            {
              "name": "response_format",
              "value": "verbose_json"
            }
          ]
        },
        "options": {}
      },
      "id": "fc726196-f62d-4ff4-9be6-a84b9dbfff9e",
      "name": "Whisper Transcribe",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [224, 0]
    },
    {
      "parameters": {
        "jsCode": "const result = $input.first().json;\n\nconst segments = result.segments || [];\nconst fullText = result.text || segments.map(s => s.text).join(' ');\nconst duration = result.duration || segments[segments.length - 1]?.end || 0;\n\n// Format timestamps\nconst timestamped = segments.map(s => {\n  const start = new Date(s.start * 1000).toISOString().substr(11, 8);\n  return `[${start}] ${s.text.trim()}`;\n}).join('\\n');\n\nreturn [{\n  json: {\n    text: fullText.trim(),\n    timestamped_text: timestamped,\n    duration_seconds: Math.round(duration),\n    segment_count: segments.length,\n    language: result.language || 'en'\n  }\n}];"
      },
      "id": "1b6f017f-849d-456f-9e4b-a0bced1d8e9f",
      "name": "Format Transcript",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [448, 0]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "transcribe/summarize",
        "responseMode": "lastNode",
        "responseData": "allEntries",
        "options": {
          "rawBody": true
        }
      },
      "id": "c2f8a2dd-cbbc-4b62-ae24-0f4a95bdf862",
      "name": "Transcribe + Summarize Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [0, 304],
      "webhookId": "69b4b2e8-9486-4aa3-b9db-fb8e6bdae98e"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://10.5.30.7:8786/v1/audio/transcriptions",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "file",
              "inputDataFieldName": "data"
            },
            {
              "name": "model",
              "value": "Systran/faster-distil-whisper-small.en"
            },
            {
              "name": "language",
              "value": "en"
            }
          ]
        },
        "options": {}
      },
      "id": "ee25bf40-99ef-472b-928d-6ef63516094c",
      "name": "Whisper Transcribe 2",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [224, 304]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://10.5.30.6:4000/v1/chat/completions",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "={{'Bearer ' + $env.LITELLM_API_KEY}}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"medium\",\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"You are a meeting/audio note summarizer. Given a transcription, provide:\\n1. A brief summary (2-3 sentences)\\n2. Key points as a bullet list\\n3. Any action items mentioned\\n\\nRespond in JSON with keys: summary, key_points (array), action_items (array)\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"Summarize this transcription:\\n\\n{{ $json.text }}\"\n    }\n  ],\n  \"max_tokens\": 500,\n  \"temperature\": 0.2,\n  \"response_format\": { \"type\": \"json_object\" }\n}",
        "options": {}
      },
      "id": "eda24425-dc26-4b4b-858e-9ae0d5e1a5e4",
      "name": "AI Summarize Audio",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [448, 304]
    },
    {
      "parameters": {
        "jsCode": "const llmResponse = $input.first().json;\nconst transcript = $('Whisper Transcribe 2').first().json;\nlet analysis;\n\ntry {\n  analysis = JSON.parse(llmResponse.choices?.[0]?.message?.content || '{}');\n} catch(e) {\n  analysis = { summary: llmResponse.choices?.[0]?.message?.content || 'Summary failed', key_points: [], action_items: [] };\n}\n\nreturn [{\n  json: {\n    transcript: transcript.text || '',\n    duration_seconds: Math.round(transcript.duration || 0),\n    language: transcript.language || 'en',\n    summary: analysis.summary,\n    key_points: analysis.key_points || [],\n    action_items: analysis.action_items || []\n  }\n}];"
      },
      "id": "cf41669b-8bf7-433b-b390-10765954b0a9",
      "name": "Format Summary Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [672, 304]
    },
    {
      "parameters": {
        "jsCode": "const t = $input.first().json;\nconst mins = Math.floor(t.duration_seconds / 60);\nconst secs = t.duration_seconds % 60;\nreturn [{ json: {\n  title: '🎙️ Transcription Complete',\n  message: `Duration: ${mins}m ${secs}s · ${t.segment_count} segments · Language: ${t.language}`,\n  priority: 3\n}}];\n"
      },
      "id": "5c692355-2a46-4c66-860a-c02a21c73597",
      "name": "Format Transcription Notify",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [672, 0]
    },
    {
      "parameters": {
        "message": "={{ $json.message }}",
        "additionalFields": {
          "priority": "={{ $json.priority }}",
          "title": "={{ $json.title }}"
        },
        "options": {
          "contentType": "text/plain"
        }
      },
      "id": "0e96240d-50e2-49f7-be62-4f57451e0543",
      "name": "Notify Transcription Done",
      "type": "n8n-nodes-base.gotify",
      "typeVersion": 1,
      "position": [896, 0],
      "credentials": {
        "gotifyApi": {
          "id": "SETUP_REQUIRED",
          "name": "Whisper"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const t = $('Format Transcript').first().json;\nconst title = `Transcript ${new Date().toLocaleDateString('en-US')}`;\nconst content = `Transcript\\nDate: ${new Date().toISOString()}\\nDuration: ${t.duration_seconds}s\\nLanguage: ${t.language}\\n\\n${t.timestamped_text || t.text}`;\nreturn [{ binary: { document: { data: Buffer.from(content,'utf-8').toString('base64'), mimeType:'text/plain', fileName: `${title}.txt` }}, json: { title } }];\n"
      },
      "id": "da9f4d8d-8c5b-413a-badd-71287dbe0a3c",
      "name": "Prepare Transcript Doc",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1120, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://paperless.paccoco.com/api/documents/post_document/",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Token {{ $env.PAPERLESS_API_TOKEN }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "document",
              "inputDataFieldName": "document"
            },
            {
              "name": "title",
              "value": "={{ $json.title }}"
            },
            {
              "name": "tags[]",
              "value": "={{ $env.PAPERLESS_TAG_TRANSCRIPTION }}"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "responseFormat": "text"
            }
          }
        }
      },
      "id": "7c84da5a-41e2-4b38-9e58-19acfd73f81d",
      "name": "Save Transcript to Paperless",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1344, 0],
      "continueOnFail": true
    },
    {
      "parameters": {
        "jsCode": "const s = $input.first().json;\nconst mins = Math.floor(s.duration_seconds / 60);\nconst points = (s.key_points || []).slice(0,3).map((p,i) => `${i+1}. ${p}`).join('\\n');\nreturn [{ json: {\n  title: '🎙️ Transcription + Summary Complete',\n  message: `${mins}m audio\\n\\nSummary: ${s.summary}\\n\\nKey points:\\n${points}`,\n  priority: 4\n}}];\n"
      },
      "id": "e55363e4-ff9b-4df4-b40a-fd23227c23e8",
      "name": "Format Summary Notify",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [896, 304]
    },
    {
      "parameters": {
        "message": "={{ $json.message }}",
        "additionalFields": {
          "priority": "={{ $json.priority }}",
          "title": "={{ $json.title }}"
        },
        "options": {
          "contentType": "text/plain"
        }
      },
      "id": "b5defea9-35a0-4a22-8769-ed9496a022f6",
      "name": "Notify Summary Done",
      "type": "n8n-nodes-base.gotify",
      "typeVersion": 1,
      "position": [1120, 304],
      "credentials": {
        "gotifyApi": {
          "id": "SETUP_REQUIRED",
          "name": "Whisper"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const s = $('Format Summary Response').first().json;\nconst title = `Audio Summary ${new Date().toLocaleDateString('en-US')}`;\nconst points = (s.key_points || []).map((p,i) => `${i+1}. ${p}`).join('\\n');\nconst actions = (s.action_items || []).map((a,i) => `${i+1}. ${a}`).join('\\n');\nconst content = [\n  `Audio Transcription & Summary`, `Date: ${new Date().toISOString()}`,\n  `Duration: ${Math.floor(s.duration_seconds/60)}m ${s.duration_seconds%60}s`,\n  `Language: ${s.language}`, '', `Summary`, `=======`, s.summary,\n  '', `Key Points`, `==========`, points,\n  ...(actions ? ['', `Action Items`, `============`, actions] : []),\n  '', `Full Transcript`, `==============`, s.transcript\n].join('\\n');\nreturn [{ binary: { document: { data: Buffer.from(content,'utf-8').toString('base64'), mimeType:'text/plain', fileName:`${title}.txt` }}, json: { title } }];\n"
      },
      "id": "1f31f608-7985-4a9a-afcf-6cf4e44150ba",
      "name": "Prepare Summary Doc",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1344, 304]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://paperless.paccoco.com/api/documents/post_document/",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Token {{ $env.PAPERLESS_API_TOKEN }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "document",
              "inputDataFieldName": "document"
            },
            {
              "name": "title",
              "value": "={{ $json.title }}"
            },
            {
              "name": "tags[]",
              "value": "={{ $env.PAPERLESS_TAG_TRANSCRIPTION }}"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "responseFormat": "text"
            }
          }
        }
      },
      "id": "e9eaee2f-d08e-4a76-af53-ed824ebfe68f",
      "name": "Save Summary to Paperless",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1568, 304],
      "continueOnFail": true
    }
  ],
  "connections": {
    "Transcription Webhook": {
      "main": [[{ "node": "Whisper Transcribe", "type": "main", "index": 0 }]]
    },
    "Whisper Transcribe": {
      "main": [[{ "node": "Format Transcript", "type": "main", "index": 0 }]]
    },
    "Transcribe + Summarize Webhook": {
      "main": [[{ "node": "Whisper Transcribe 2", "type": "main", "index": 0 }]]
    },
    "Whisper Transcribe 2": {
      "main": [[{ "node": "AI Summarize Audio", "type": "main", "index": 0 }]]
    },
    "AI Summarize Audio": {
      "main": [[{ "node": "Format Summary Response", "type": "main", "index": 0 }]]
    },
    "Format Transcript": {
      "main": [[{ "node": "Format Transcription Notify", "type": "main", "index": 0 }]]
    },
    "Format Transcription Notify": {
      "main": [[{ "node": "Notify Transcription Done", "type": "main", "index": 0 }]]
    },
    "Notify Transcription Done": {
      "main": [[{ "node": "Prepare Transcript Doc", "type": "main", "index": 0 }]]
    },
    "Prepare Transcript Doc": {
      "main": [[{ "node": "Save Transcript to Paperless", "type": "main", "index": 0 }]]
    },
    "Format Summary Response": {
      "main": [[{ "node": "Format Summary Notify", "type": "main", "index": 0 }]]
    },
    "Format Summary Notify": {
      "main": [[{ "node": "Notify Summary Done", "type": "main", "index": 0 }]]
    },
    "Notify Summary Done": {
      "main": [[{ "node": "Prepare Summary Doc", "type": "main", "index": 0 }]]
    },
    "Prepare Summary Doc": {
      "main": [[{ "node": "Save Summary to Paperless", "type": "main", "index": 0 }]]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "staticData": null,
  "meta": null,
  "pinData": {},
  "tags": [
    { "name": "transcription" },
    { "name": "whisper" },
    { "name": "ai" }
  ]
}
