{
  "id": "patchwellTranscribeToNotes",
  "name": "Patchwell: transcribe a recording into speaker-labelled notes",
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "nodes": [
    {
      "id": "n1",
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "n2",
      "name": "Recording",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "url",
              "type": "string",
              "value": "https://patchwell.io/samples/nasa_interview_30s.mp3"
            }
          ]
        },
        "options": {}
      },
      "notes": "Put your audio or video link here, or replace Start + Recording with any trigger that gives a url."
    },
    {
      "id": "n3",
      "name": "Transcribe",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        0
      ],
      "parameters": {
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "method": "POST",
        "url": "https://patchwell.io/v1/transcribe",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Idempotency-Key",
              "value": "={{ 'n8n-' + $json.url.slice(-180) }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ url: $json.url }) }}",
        "options": {
          "timeout": 170000
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "patchwellApi",
          "name": "Patchwell API"
        }
      },
      "notes": "Same link = same Idempotency-Key, so a retry or a re-run never charges twice."
    },
    {
      "id": "n4",
      "name": "Still running?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        660,
        0
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.status }}",
              "rightValue": "running",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "n5",
      "name": "Wait 30 s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        880,
        -160
      ],
      "parameters": {
        "amount": 30
      }
    },
    {
      "id": "n6",
      "name": "Check job",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1100,
        -160
      ],
      "parameters": {
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "method": "GET",
        "url": "=https://patchwell.io/v1/jobs/{{ $json.job_id }}",
        "options": {}
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "patchwellApi",
          "name": "Patchwell API"
        }
      }
    },
    {
      "id": "n7",
      "name": "Notes (Markdown)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        160
      ],
      "parameters": {
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "method": "POST",
        "url": "https://patchwell.io/v1/export?format=md",
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "application/json",
        "body": "={{ JSON.stringify($json) }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "text",
              "outputPropertyName": "notes"
            }
          }
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "patchwellApi",
          "name": "Patchwell API"
        }
      },
      "notes": "Swap format=md for docx, srt, vtt, txt or csv. Send the notes anywhere next: Google Docs, Notion, Slack, email."
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Recording",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recording": {
      "main": [
        [
          {
            "node": "Transcribe",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe": {
      "main": [
        [
          {
            "node": "Still running?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Still running?": {
      "main": [
        [
          {
            "node": "Wait 30 s",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notes (Markdown)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 30 s": {
      "main": [
        [
          {
            "node": "Check job",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check job": {
      "main": [
        [
          {
            "node": "Still running?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}