{
  "name": "Call Transcript Approval Flow",
  "nodes": [
    {
      "parameters": {
        "path": "call-transcript",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "WebhookIn",
      "name": "Transcript Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        260,
        260
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://api:8080/webhooks/n8n/call-transcript",
        "sendBody": true,
        "contentType": "json",
        "jsonBody": "={{ JSON.stringify($json.body || $json) }}"
      },
      "id": "AnalyzeTranscript",
      "name": "Analyze Transcript",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        560,
        260
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "approval_id",
              "name": "approval_id",
              "value": "={{ $json.approval.id }}",
              "type": "string"
            },
            {
              "id": "telegram_text",
              "name": "telegram_text",
              "value": "={{ 'Approve follow-up for ' + $json.customer_id + '\\nScore: ' + $json.score + '/100\\nRisk: ' + $json.analysis.risk_level + '\\nNext action: ' + $json.analysis.next_action + '\\nApproval ID: ' + $json.approval.id }}",
              "type": "string"
            },
            {
              "id": "crm_operation",
              "name": "crm_operation",
              "value": "={{ $json.analysis.crm_update.adapter + '/' + $json.analysis.crm_update.operation }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "BuildTelegramApprovalPayload",
      "name": "Build Telegram Approval Payload",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        820,
        260
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}"
      },
      "id": "Respond",
      "name": "Return Approval Item",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1080,
        260
      ]
    }
  ],
  "connections": {
    "Transcript Webhook": {
      "main": [
        [
          {
            "node": "Analyze Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Transcript": {
      "main": [
        [
          {
            "node": "Build Telegram Approval Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Telegram Approval Payload": {
      "main": [
        [
          {
            "node": "Return Approval Item",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ai-ops-workflow-kit"
}