{
  "name": "Recover missed inbound calls with authorized Ringee AI callbacks",
  "nodes": [
    {
      "parameters": {
        "errorMessage": "A service step failed. Inspect the failed execution and the source record. Reconcile any accepted Ringee call before retrying; never change its call key to bypass an ambiguous failure."
      },
      "id": "9028ced4-9687-43b5-8740-34ccea683665",
      "name": "Failure requires reconciliation",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        2300,
        1700
      ]
    },
    {
      "parameters": {
        "content": "### How it works\nA signed call.missed event leads to a call-detail read to confirm inbound direction. An existing contact and permission row are retrieved. Only recent human inbound misses with documented callback authorization pass. AI and callback-generated events are rejected.\n\nThis template is for Local businesses, clinics, professional services and support teams. A recorded callback outcome and a team notification without recursive callback loops. Ringee runs the voice conversation; n8n manages the surrounding records and decisions.\n\n### Setup\nInstall the verified **n8n-nodes-ringee 0.1.2** package. Create a Ringee account and a workspace Custom Integration, then select its API key in an n8n credential. Choose your already configured voice agent, keep callsEnabled false, and configure permission evidence, recipient timezones and a unique client namespace. Connect Ringee Trigger, Google Sheets, Slack and select every blank destination. Signed triggers also need the Signing Secret and the integration Outbound URL. Import into a new inactive workflow and test dedicated demonstration records before activation.\n\n### Customization\nStart with one authorized call per run. Change calling days and hours for your recipients; this does not establish legal compliance. No automatic redial is included. Read the companion setup guide for column names, field mappings and limitations. [Create your Ringee account](https://ringee.io/integrations/n8n?utm_source=n8n&utm_medium=template&utm_campaign=ringee_workflows&utm_content=04-missed-call-recovery).",
        "width": 570,
        "height": 700,
        "color": 1
      },
      "id": "ae947e58-4e1f-4a58-8a8f-7598b84d88c7",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -600,
        -320
      ]
    },
    {
      "parameters": {
        "content": "## Configure the source\nSelect credentials and destinations. Calling workflows require trusted permission evidence and an IANA timezone for each recipient.",
        "width": 1600,
        "height": 400,
        "color": 7
      },
      "id": "76d38e61-5f5f-40bd-8abe-0131f244e2ee",
      "name": "1. Configure and admit records",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        80
      ]
    },
    {
      "parameters": {
        "content": "## Control billable work\nThe model cannot grant consent. Keep persistent keys, serial processing and the one-to-five call cap. Ringee also enforces its financial, DNC and capacity gates.",
        "width": 1500,
        "height": 470,
        "color": 7
      },
      "id": "d89c6247-0733-4145-8830-a98712f85478",
      "name": "2. One authorized call",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1650,
        80
      ]
    },
    {
      "parameters": {
        "content": "## Wait for real results\nCompletion and analysis are separate. Two bounded reads preserve pending or missing-analysis states. Failures require inspection; a result read never starts a call.",
        "width": 1400,
        "height": 470,
        "color": 7
      },
      "id": "489df8b4-d072-4bb3-86ec-2ca177b6813e",
      "name": "3. Reconcile the result",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        3200,
        80
      ]
    },
    {
      "parameters": {
        "content": "## Update the destination\nConfigure the private results sheet and team channel. Review CRM snapshot ordering and task ownership before activation. Do not include sensitive transcripts in Slack.",
        "width": 1900,
        "height": 470,
        "color": 7
      },
      "id": "51a0ad82-d570-41e2-8735-38ebd016f0a6",
      "name": "4. Deliver the business outcome",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        4650,
        80
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "16e49af5-bf98-4951-807d-ba7d32edfad5",
              "name": "callsEnabled",
              "value": false,
              "type": "boolean"
            },
            {
              "id": "38c475b2-ca9f-435e-87d4-393a48f707bb",
              "name": "clientNamespace",
              "value": "CHANGE_ME_CLIENT_NAMESPACE",
              "type": "string"
            },
            {
              "id": "f0fbcb2e-16a6-4c00-8f3f-b682f90407cd",
              "name": "maxCallsPerRun",
              "value": 1,
              "type": "number"
            },
            {
              "id": "f759d89f-4700-401a-8aea-8692de93e466",
              "name": "startHour",
              "value": 9,
              "type": "number"
            },
            {
              "id": "bddbbc9b-7e81-4604-820b-5d0cce9d2a5b",
              "name": "endHour",
              "value": 17,
              "type": "number"
            },
            {
              "id": "735bf147-d0e1-4396-8950-2bd2c3666057",
              "name": "callingDays",
              "value": "1,2,3,4,5",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "id": "b6911708-f57b-4ec8-83f6-53168b5ffef9",
      "name": "Configuration",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [
        260,
        300
      ]
    },
    {
      "parameters": {},
      "id": "5292214b-d9d1-47f1-8d86-53ca02fc9042",
      "name": "Held for manual review",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1800,
        700
      ]
    },
    {
      "parameters": {
        "events": [
          "call.missed"
        ],
        "options": {}
      },
      "id": "d20da901-b818-4846-834a-4d47eb6fd7b8",
      "name": "Missed inbound call",
      "type": "n8n-nodes-ringee.ringeeTrigger",
      "typeVersion": 1,
      "position": [
        0,
        300
      ],
      "webhookId": "95b96d2d-0542-4b96-8dab-f4ca2ed8b963"
    },
    {
      "parameters": {
        "resource": "call",
        "operation": "get",
        "callId": "={{ $('Missed inbound call').item.json.data.callId }}",
        "simplify": false
      },
      "id": "11d71ffa-2915-41df-8bc6-ba59a6405788",
      "name": "Read missed call",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [
        520,
        300
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "resource": "contact",
        "operation": "getMany",
        "returnAll": false,
        "limit": 1,
        "filters": {
          "query": "={{ $('Missed inbound call').item.json.data.fromNumber }}"
        }
      },
      "id": "d0d8f9cd-953e-453f-802f-b7af1b48c6fd",
      "name": "Find the Ringee contact",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [
        760,
        300
      ],
      "onError": "continueErrorOutput",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "resource": "sheet",
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "phone",
              "lookupValue": "={{ $('Missed inbound call').item.json.data.fromNumber }}"
            }
          ]
        },
        "combineFilters": "AND"
      },
      "id": "7156727e-d52d-4566-8385-6f9d3715cedc",
      "name": "Read existing callback permission",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1000,
        300
      ],
      "onError": "continueErrorOutput",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "function normalizeRecords(items, config, now, kind, sourceEvent = null) {\n\tconst yes = (v) => v === true || String(v).trim().toLowerCase() === 'true';\n\tconst no = (v) => v === false || String(v).trim().toLowerCase() === 'false';\n\tconst cleanPhone = (v) => {\n\t\tconst text = String(v ?? '').trim();\n\t\tif (!/^(?:\\+|00)[\\d\\s().-]+$/.test(text)) return '';\n\t\treturn text.replace(/^00/, '+').replace(/[\\s().-]/g, '');\n\t};\n\tconst safeId = (v) => /^[A-Za-z0-9_.:@/+~=-]{1,120}$/.test(String(v ?? ''));\n\tconst namespace = String(config.clientNamespace ?? '');\n\tconst limit = Math.max(1, Math.min(5, Math.floor(Number(config.maxCallsPerRun) || 1)));\n\tconst seen = new Set();\n\tlet accepted = 0;\n\treturn items.map((item, index) => {\n\t\tlet row = { ...(item.json.body ?? item.json) };\n\t\tlet extra = {};\n\t\tif (kind === 'appointment' && row.eventId) {\n\t\t\textra = {\n\t\t\t\teventId: row.eventId,\n\t\t\t\tappointmentStart: row.appointmentStart,\n\t\t\t\ttitle: row.title,\n\t\t\t\tinReminderWindow: Date.parse(row.appointmentStart ?? '') > now.toMillis(),\n\t\t\t};\n\t\t} else if (kind === 'appointment') {\n\t\t\tconst description = String(row.description ?? '');\n\t\t\tconst line = (key) =>\n\t\t\t\tdescription.match(new RegExp('^' + key + ':[ \\\\t]*([^\\\\r\\\\n]*)', 'im'))?.[1]?.trim() ?? '';\n\t\t\tconst startMillis = Date.parse(row.start?.dateTime ?? '');\n\t\t\tconst anchor = Date.parse(config.runStartedAt ?? '') || now.toMillis();\n\t\t\tconst minutes = (startMillis - anchor) / 60000;\n\t\t\textra = {\n\t\t\t\teventId: row.id,\n\t\t\t\tappointmentStart: row.start?.dateTime ?? '',\n\t\t\t\ttitle: row.summary ?? 'Appointment',\n\t\t\t\tinReminderWindow:\n\t\t\t\t\tNumber.isFinite(startMillis) &&\n\t\t\t\t\tminutes >= Number(config.reminderMinutes) &&\n\t\t\t\t\tminutes < Number(config.reminderMinutes) + 15 &&\n\t\t\t\t\trow.status !== 'cancelled',\n\t\t\t};\n\t\t\trow = {\n\t\t\t\trecordId: row.id,\n\t\t\t\tphone: line('Phone'),\n\t\t\t\tname: line('Name'),\n\t\t\t\ttimezone: line('Timezone'),\n\t\t\t\tconsent: line('Consent'),\n\t\t\t\tconsentRecordedAt: line('ConsentRecordedAt'),\n\t\t\t\tauthorized: line('Authorized'),\n\t\t\t\tsuppressionChecked: line('SuppressionChecked'),\n\t\t\t\tdoNotCall: line('DoNotCall'),\n\t\t\t\tattemptCount: line('AttemptCount'),\n\t\t\t\temail: line('Email'),\n\t\t\t};\n\t\t}\n\t\tif (kind === 'callback') {\n\t\t\tconst event = sourceEvent ?? {};\n\t\t\tconst data = event.data ?? {};\n\t\t\tconst timestamp = Date.parse(event.occurredAt ?? '');\n\t\t\tconst age = now.toMillis() - timestamp;\n\t\t\tconst isInboundMiss =\n\t\t\t\tevent.event === 'call.missed' &&\n\t\t\t\t(data.direction === 'inbound' || data.call?.direction === 'inbound') &&\n\t\t\t\t!data.agent &&\n\t\t\t\t!data.call?.voiceAgentCall &&\n\t\t\t\t!String(data.externalId ?? '').startsWith('ringee-callback:') &&\n\t\t\t\tage >= 0 &&\n\t\t\t\tage <= 30 * 60000;\n\t\t\textra = { eventId: event.eventId, missedCallId: data.callId, isInboundMiss };\n\t\t\trow = { ...row, recordId: data.callId, phone: data.fromNumber, name: row.name ?? 'Caller' };\n\t\t}\n\t\tconst phone = cleanPhone(row.phone);\n\t\tconst local = now.setZone(String(row.timezone ?? ''));\n\t\tconst reasons = [];\n\t\tif (!yes(config.callsEnabled)) reasons.push('calls_disabled');\n\t\tif (!/^[A-Za-z0-9_.-]{1,120}$/.test(namespace) || namespace.includes('CHANGE_ME'))\n\t\t\treasons.push('configure_client_namespace');\n\t\tif (!safeId(row.recordId)) reasons.push('missing_or_invalid_record_id');\n\t\tif (!/^\\+[1-9]\\d{7,14}$/.test(phone)) reasons.push('invalid_e164_phone');\n\t\tif (!yes(row.authorized) || !yes(row.consent)) reasons.push('authorization_or_consent_missing');\n\t\tconst consentAt = Date.parse(row.consentRecordedAt ?? '');\n\t\tif (!Number.isFinite(consentAt) || consentAt > now.toMillis())\n\t\t\treasons.push('invalid_consent_timestamp');\n\t\tif (!yes(row.suppressionChecked) || !no(row.doNotCall))\n\t\t\treasons.push('suppression_check_required');\n\t\tif (\n\t\t\t!(\n\t\t\t\trow.attemptCount === 0 ||\n\t\t\t\t(typeof row.attemptCount === 'string' && row.attemptCount.trim() === '0')\n\t\t\t)\n\t\t)\n\t\t\treasons.push('already_attempted_or_attempt_count_missing');\n\t\tconst startHour = Number(config.startHour);\n\t\tconst endHour = Number(config.endHour);\n\t\tconst days = String(config.callingDays ?? '')\n\t\t\t.split(',')\n\t\t\t.map(Number);\n\t\tif (!local.isValid || !String(row.timezone ?? '').includes('/'))\n\t\t\treasons.push('recipient_iana_timezone_required');\n\t\telse if (\n\t\t\t!Number.isInteger(startHour) ||\n\t\t\t!Number.isInteger(endHour) ||\n\t\t\tstartHour < 0 ||\n\t\t\tendHour > 24 ||\n\t\t\tstartHour >= endHour ||\n\t\t\t!days.includes(local.weekday) ||\n\t\t\tlocal.hour < startHour ||\n\t\t\tlocal.hour >= endHour\n\t\t)\n\t\t\treasons.push('outside_calling_hours');\n\t\tif (kind === 'appointment' && !extra.inReminderWindow) reasons.push('not_in_reminder_window');\n\t\tif (kind === 'callback' && !extra.isInboundMiss)\n\t\t\treasons.push('not_a_recent_human_inbound_missed_call');\n\t\tif (kind === 'followup') {\n\t\t\tconst due = Date.parse(row.followUpAt ?? '');\n\t\t\tif (!Number.isFinite(due) || due > now.toMillis() || now.toMillis() - due > 86400000)\n\t\t\t\treasons.push('followup_not_due');\n\t\t\tif (String(row.stage ?? '') !== String(config.eligibleStage ?? 'follow_up'))\n\t\t\t\treasons.push('ineligible_crm_stage');\n\t\t}\n\t\tif (kind === 'invoice') {\n\t\t\tconst due = Date.parse(row.dueAt ?? '');\n\t\t\tconst daysToDue = (due - now.toMillis()) / 86400000;\n\t\t\tif (\n\t\t\t\trow.invoiceStatus !== 'open' ||\n\t\t\t\t!(Number(row.amountDue) > 0) ||\n\t\t\t\t!Number.isFinite(due) ||\n\t\t\t\tdaysToDue > 3 ||\n\t\t\t\tdaysToDue < -30 ||\n\t\t\t\tyes(row.disputed) ||\n\t\t\t\t!no(row.disputed)\n\t\t\t)\n\t\t\t\treasons.push('invoice_not_eligible');\n\t\t}\n\t\tif (kind === 'agent' && (!yes(row.approved) || !safeId(row.authorizationId)))\n\t\t\treasons.push('human_approval_required');\n\t\tif (['qualification', 'speed', 'booking', 'sheet'].includes(kind) && row.status !== 'ready')\n\t\t\treasons.push('record_not_ready');\n\t\t// A retry must retain the missed event's recipient-local day across midnight.\n\t\tconst eventMillis = Date.parse(sourceEvent?.occurredAt ?? '');\n\t\tconst day =\n\t\t\tkind === 'callback' && local.isValid && Number.isFinite(eventMillis)\n\t\t\t\t? local.minus({ milliseconds: now.toMillis() - eventMillis }).toISODate()\n\t\t\t\t: local.isValid\n\t\t\t\t\t? local.toISODate()\n\t\t\t\t\t: now.toISODate();\n\t\tconst identity =\n\t\t\tkind === 'callback'\n\t\t\t\t? phone + ':' + day\n\t\t\t\t: kind === 'agent'\n\t\t\t\t\t? row.authorizationId\n\t\t\t\t\t: row.recordId;\n\t\tconst callKey = 'ringee-' + kind + ':' + namespace + ':' + String(identity ?? '');\n\t\tif (callKey.length > 255) reasons.push('call_key_too_long');\n\t\tif (seen.has(phone)) reasons.push('duplicate_phone_in_input');\n\t\tif (!reasons.length && accepted >= limit) reasons.push('run_call_limit_reached');\n\t\tif (!reasons.length) {\n\t\t\taccepted++;\n\t\t\tseen.add(phone);\n\t\t}\n\t\treturn {\n\t\t\tjson: {\n\t\t\t\t...row,\n\t\t\t\t...extra,\n\t\t\t\t...(kind === 'callback' ? { missedEventOccurredAt: sourceEvent?.occurredAt ?? '' } : {}),\n\t\t\t\tphone,\n\t\t\t\tcallKey,\n\t\t\t\teligible: reasons.length === 0,\n\t\t\t\tdecision: reasons.length ? 'held' : 'eligible',\n\t\t\t\tholdReasons: reasons.join(', '),\n\t\t\t\ttemplate: kind,\n\t\t\t},\n\t\t\tpairedItem: { item: index },\n\t\t};\n\t});\n}\nreturn normalizeRecords($input.all(),$('Configuration').first().json,$now,\"callback\",{...$('Missed inbound call').item.json,data:{...$('Missed inbound call').item.json.data,call:$('Read missed call').item.json}});"
      },
      "id": "01612f29-1991-4d1a-85c1-cef1b898e926",
      "name": "Normalize and check eligibility",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1280,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "acde5cc3-caa5-464d-8073-1fc14709d69c",
              "leftValue": "={{ $json.eligible === true }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "183cf52a-6fac-4637-8c58-b2bcdc514ee3",
      "name": "Eligible for one authorized call?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        1520,
        300
      ]
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {}
      },
      "id": "9fb866b8-5b96-4d3b-8655-b4efb52ff6a7",
      "name": "Process one record",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        1760,
        300
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "function normalizeRecords(items, config, now, kind, sourceEvent = null) {\n\tconst yes = (v) => v === true || String(v).trim().toLowerCase() === 'true';\n\tconst no = (v) => v === false || String(v).trim().toLowerCase() === 'false';\n\tconst cleanPhone = (v) => {\n\t\tconst text = String(v ?? '').trim();\n\t\tif (!/^(?:\\+|00)[\\d\\s().-]+$/.test(text)) return '';\n\t\treturn text.replace(/^00/, '+').replace(/[\\s().-]/g, '');\n\t};\n\tconst safeId = (v) => /^[A-Za-z0-9_.:@/+~=-]{1,120}$/.test(String(v ?? ''));\n\tconst namespace = String(config.clientNamespace ?? '');\n\tconst limit = Math.max(1, Math.min(5, Math.floor(Number(config.maxCallsPerRun) || 1)));\n\tconst seen = new Set();\n\tlet accepted = 0;\n\treturn items.map((item, index) => {\n\t\tlet row = { ...(item.json.body ?? item.json) };\n\t\tlet extra = {};\n\t\tif (kind === 'appointment' && row.eventId) {\n\t\t\textra = {\n\t\t\t\teventId: row.eventId,\n\t\t\t\tappointmentStart: row.appointmentStart,\n\t\t\t\ttitle: row.title,\n\t\t\t\tinReminderWindow: Date.parse(row.appointmentStart ?? '') > now.toMillis(),\n\t\t\t};\n\t\t} else if (kind === 'appointment') {\n\t\t\tconst description = String(row.description ?? '');\n\t\t\tconst line = (key) =>\n\t\t\t\tdescription.match(new RegExp('^' + key + ':[ \\\\t]*([^\\\\r\\\\n]*)', 'im'))?.[1]?.trim() ?? '';\n\t\t\tconst startMillis = Date.parse(row.start?.dateTime ?? '');\n\t\t\tconst anchor = Date.parse(config.runStartedAt ?? '') || now.toMillis();\n\t\t\tconst minutes = (startMillis - anchor) / 60000;\n\t\t\textra = {\n\t\t\t\teventId: row.id,\n\t\t\t\tappointmentStart: row.start?.dateTime ?? '',\n\t\t\t\ttitle: row.summary ?? 'Appointment',\n\t\t\t\tinReminderWindow:\n\t\t\t\t\tNumber.isFinite(startMillis) &&\n\t\t\t\t\tminutes >= Number(config.reminderMinutes) &&\n\t\t\t\t\tminutes < Number(config.reminderMinutes) + 15 &&\n\t\t\t\t\trow.status !== 'cancelled',\n\t\t\t};\n\t\t\trow = {\n\t\t\t\trecordId: row.id,\n\t\t\t\tphone: line('Phone'),\n\t\t\t\tname: line('Name'),\n\t\t\t\ttimezone: line('Timezone'),\n\t\t\t\tconsent: line('Consent'),\n\t\t\t\tconsentRecordedAt: line('ConsentRecordedAt'),\n\t\t\t\tauthorized: line('Authorized'),\n\t\t\t\tsuppressionChecked: line('SuppressionChecked'),\n\t\t\t\tdoNotCall: line('DoNotCall'),\n\t\t\t\tattemptCount: line('AttemptCount'),\n\t\t\t\temail: line('Email'),\n\t\t\t};\n\t\t}\n\t\tif (kind === 'callback') {\n\t\t\tconst event = sourceEvent ?? {};\n\t\t\tconst data = event.data ?? {};\n\t\t\tconst timestamp = Date.parse(event.occurredAt ?? '');\n\t\t\tconst age = now.toMillis() - timestamp;\n\t\t\tconst isInboundMiss =\n\t\t\t\tevent.event === 'call.missed' &&\n\t\t\t\t(data.direction === 'inbound' || data.call?.direction === 'inbound') &&\n\t\t\t\t!data.agent &&\n\t\t\t\t!data.call?.voiceAgentCall &&\n\t\t\t\t!String(data.externalId ?? '').startsWith('ringee-callback:') &&\n\t\t\t\tage >= 0 &&\n\t\t\t\tage <= 30 * 60000;\n\t\t\textra = { eventId: event.eventId, missedCallId: data.callId, isInboundMiss };\n\t\t\trow = { ...row, recordId: data.callId, phone: data.fromNumber, name: row.name ?? 'Caller' };\n\t\t}\n\t\tconst phone = cleanPhone(row.phone);\n\t\tconst local = now.setZone(String(row.timezone ?? ''));\n\t\tconst reasons = [];\n\t\tif (!yes(config.callsEnabled)) reasons.push('calls_disabled');\n\t\tif (!/^[A-Za-z0-9_.-]{1,120}$/.test(namespace) || namespace.includes('CHANGE_ME'))\n\t\t\treasons.push('configure_client_namespace');\n\t\tif (!safeId(row.recordId)) reasons.push('missing_or_invalid_record_id');\n\t\tif (!/^\\+[1-9]\\d{7,14}$/.test(phone)) reasons.push('invalid_e164_phone');\n\t\tif (!yes(row.authorized) || !yes(row.consent)) reasons.push('authorization_or_consent_missing');\n\t\tconst consentAt = Date.parse(row.consentRecordedAt ?? '');\n\t\tif (!Number.isFinite(consentAt) || consentAt > now.toMillis())\n\t\t\treasons.push('invalid_consent_timestamp');\n\t\tif (!yes(row.suppressionChecked) || !no(row.doNotCall))\n\t\t\treasons.push('suppression_check_required');\n\t\tif (\n\t\t\t!(\n\t\t\t\trow.attemptCount === 0 ||\n\t\t\t\t(typeof row.attemptCount === 'string' && row.attemptCount.trim() === '0')\n\t\t\t)\n\t\t)\n\t\t\treasons.push('already_attempted_or_attempt_count_missing');\n\t\tconst startHour = Number(config.startHour);\n\t\tconst endHour = Number(config.endHour);\n\t\tconst days = String(config.callingDays ?? '')\n\t\t\t.split(',')\n\t\t\t.map(Number);\n\t\tif (!local.isValid || !String(row.timezone ?? '').includes('/'))\n\t\t\treasons.push('recipient_iana_timezone_required');\n\t\telse if (\n\t\t\t!Number.isInteger(startHour) ||\n\t\t\t!Number.isInteger(endHour) ||\n\t\t\tstartHour < 0 ||\n\t\t\tendHour > 24 ||\n\t\t\tstartHour >= endHour ||\n\t\t\t!days.includes(local.weekday) ||\n\t\t\tlocal.hour < startHour ||\n\t\t\tlocal.hour >= endHour\n\t\t)\n\t\t\treasons.push('outside_calling_hours');\n\t\tif (kind === 'appointment' && !extra.inReminderWindow) reasons.push('not_in_reminder_window');\n\t\tif (kind === 'callback' && !extra.isInboundMiss)\n\t\t\treasons.push('not_a_recent_human_inbound_missed_call');\n\t\tif (kind === 'followup') {\n\t\t\tconst due = Date.parse(row.followUpAt ?? '');\n\t\t\tif (!Number.isFinite(due) || due > now.toMillis() || now.toMillis() - due > 86400000)\n\t\t\t\treasons.push('followup_not_due');\n\t\t\tif (String(row.stage ?? '') !== String(config.eligibleStage ?? 'follow_up'))\n\t\t\t\treasons.push('ineligible_crm_stage');\n\t\t}\n\t\tif (kind === 'invoice') {\n\t\t\tconst due = Date.parse(row.dueAt ?? '');\n\t\t\tconst daysToDue = (due - now.toMillis()) / 86400000;\n\t\t\tif (\n\t\t\t\trow.invoiceStatus !== 'open' ||\n\t\t\t\t!(Number(row.amountDue) > 0) ||\n\t\t\t\t!Number.isFinite(due) ||\n\t\t\t\tdaysToDue > 3 ||\n\t\t\t\tdaysToDue < -30 ||\n\t\t\t\tyes(row.disputed) ||\n\t\t\t\t!no(row.disputed)\n\t\t\t)\n\t\t\t\treasons.push('invoice_not_eligible');\n\t\t}\n\t\tif (kind === 'agent' && (!yes(row.approved) || !safeId(row.authorizationId)))\n\t\t\treasons.push('human_approval_required');\n\t\tif (['qualification', 'speed', 'booking', 'sheet'].includes(kind) && row.status !== 'ready')\n\t\t\treasons.push('record_not_ready');\n\t\t// A retry must retain the missed event's recipient-local day across midnight.\n\t\tconst eventMillis = Date.parse(sourceEvent?.occurredAt ?? '');\n\t\tconst day =\n\t\t\tkind === 'callback' && local.isValid && Number.isFinite(eventMillis)\n\t\t\t\t? local.minus({ milliseconds: now.toMillis() - eventMillis }).toISODate()\n\t\t\t\t: local.isValid\n\t\t\t\t\t? local.toISODate()\n\t\t\t\t\t: now.toISODate();\n\t\tconst identity =\n\t\t\tkind === 'callback'\n\t\t\t\t? phone + ':' + day\n\t\t\t\t: kind === 'agent'\n\t\t\t\t\t? row.authorizationId\n\t\t\t\t\t: row.recordId;\n\t\tconst callKey = 'ringee-' + kind + ':' + namespace + ':' + String(identity ?? '');\n\t\tif (callKey.length > 255) reasons.push('call_key_too_long');\n\t\tif (seen.has(phone)) reasons.push('duplicate_phone_in_input');\n\t\tif (!reasons.length && accepted >= limit) reasons.push('run_call_limit_reached');\n\t\tif (!reasons.length) {\n\t\t\taccepted++;\n\t\t\tseen.add(phone);\n\t\t}\n\t\treturn {\n\t\t\tjson: {\n\t\t\t\t...row,\n\t\t\t\t...extra,\n\t\t\t\t...(kind === 'callback' ? { missedEventOccurredAt: sourceEvent?.occurredAt ?? '' } : {}),\n\t\t\t\tphone,\n\t\t\t\tcallKey,\n\t\t\t\teligible: reasons.length === 0,\n\t\t\t\tdecision: reasons.length ? 'held' : 'eligible',\n\t\t\t\tholdReasons: reasons.join(', '),\n\t\t\t\ttemplate: kind,\n\t\t\t},\n\t\t\tpairedItem: { item: index },\n\t\t};\n\t});\n}\nreturn normalizeRecords($input.all(),$('Configuration').first().json,$now,\"callback\",{...$('Missed inbound call').item.json,data:{...$('Missed inbound call').item.json.data,call:$('Read missed call').item.json}});"
      },
      "id": "28232d4d-0b79-42e7-837a-296c4c074b03",
      "name": "Recheck hours before dialing",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2000,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "2281d588-0264-434d-8eeb-f67cb16f91d3",
              "leftValue": "={{ $json.eligible === true }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "6b575be6-4bc0-4ca2-8d74-3827d6bfdf05",
      "name": "Still eligible now?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        2240,
        300
      ]
    },
    {
      "parameters": {
        "resource": "contact",
        "operation": "createOrUpdate",
        "phoneNumber": "={{ $('Recheck hours before dialing').item.json.phone }}",
        "additionalFields": {
          "name": "={{ $('Recheck hours before dialing').item.json.name }}",
          "email": "={{ $('Recheck hours before dialing').item.json.email || '' }}",
          "source": "n8n 04-missed-call-recovery"
        }
      },
      "id": "b5267fb2-a778-49a0-8249-351e6127775b",
      "name": "Create or update Ringee contact",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [
        2480,
        300
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "resource": "aiAgent",
        "operation": "startCall",
        "agentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "phoneNumber": "={{ (function phoneAtDialTime(row, config, now) {\n\tconst local = now.setZone(String(row.timezone ?? ''));\n\tconst enabled = config.callsEnabled === true || config.callsEnabled === 'true';\n\tconst days = String(config.callingDays ?? '')\n\t\t.split(',')\n\t\t.map(Number);\n\tif (\n\t\t!enabled ||\n\t\trow.eligible !== true ||\n\t\t!local.isValid ||\n\t\t!days.includes(local.weekday) ||\n\t\tlocal.hour < Number(config.startHour) ||\n\t\tlocal.hour >= Number(config.endHour)\n\t) {\n\t\tthrow new Error(\n\t\t\t'The approved calling window is no longer open. Hold this record for manual review.',\n\t\t);\n\t}\n\tif (!/^\\+[1-9]\\d{7,14}$/.test(String(row.phone ?? '')))\n\t\tthrow new Error('A valid international phone number is required.');\n\tif (row.appointmentStart && Date.parse(row.appointmentStart) <= now.toMillis())\n\t\tthrow new Error('The appointment has already started.');\n\tif (row.template === 'callback') {\n\t\tconst age = now.toMillis() - Date.parse(row.missedEventOccurredAt ?? '');\n\t\tif (!Number.isFinite(age) || age < 0 || age > 30 * 60000)\n\t\t\tthrow new Error('The missed call is no longer recent. Hold for manual review.');\n\t}\n\treturn row.phone;\n})($('Recheck hours before dialing').item.json, $('Configuration').first().json, $now) }}",
        "variables": {
          "mappingMode": "defineBelow",
          "value": {
            "first_name": "={{ String($('Recheck hours before dialing').item.json.name || 'there').split(' ')[0] }}",
            "notification": "Please follow up on the authorized customer request."
          },
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "externalId": "={{ $('Recheck hours before dialing').item.json.callKey }}",
          "idempotencyKey": "={{ $('Recheck hours before dialing').item.json.callKey }}",
          "metadata": "={{ JSON.stringify({source_record_id:$('Recheck hours before dialing').item.json.recordId,template_slug:\"04-missed-call-recovery\"}) }}"
        }
      },
      "id": "0cfd7372-8b60-4cd9-87b9-26b012abdc47",
      "name": "Start authorized call",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [
        2720,
        300
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "return $input.all().map((item,index)=>({json:{...$('Recheck hours before dialing').item.json,...item.json},pairedItem:{item:index}}));"
      },
      "id": "4af8f9a2-07de-45cb-8f67-7a5d7d1a7f99",
      "name": "Remember accepted call",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3480,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "b835c187-d22c-4da8-8da0-c6c623af872e",
              "leftValue": "={{ $json.queued === true }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "5279acdb-7fd6-435b-8d16-9cceb8b0d382",
      "name": "Was the call queued?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        3720,
        300
      ]
    },
    {
      "parameters": {
        "resource": "aiAgent",
        "operation": "cancelCall",
        "callId": "={{ $('Remember accepted call').item.json.call_id }}"
      },
      "id": "98142214-04a8-40aa-82ad-f94c6d0a6576",
      "name": "Withdraw queued call",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [
        3720,
        680
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "amount": 2,
        "unit": "minutes"
      },
      "id": "de93657b-7077-4237-8df0-fad986ada6f6",
      "name": "Wait for call completion",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        3960,
        300
      ],
      "webhookId": "7bbca5d0-c718-41b0-8244-48e43bc76301"
    },
    {
      "parameters": {
        "resource": "aiAgent",
        "operation": "getCallResult",
        "callId": "={{ $('Remember accepted call').item.json.call_id }}"
      },
      "id": "79bf987a-065d-4c3a-887f-d4c45f18157d",
      "name": "Read call result",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [
        4200,
        300
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "a4e55dfc-eb87-4222-89b5-bac6e8265bb1",
              "leftValue": "={{ $json.finished === true && (Boolean($json.outcome || $json.summary) || ['cancelled','expired','no_answer','busy','voicemail','failed'].includes($json.status)) }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "2ea2b6dc-43cd-4f57-8784-51364e4fbbac",
      "name": "Final status and analysis?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        4440,
        300
      ]
    },
    {
      "parameters": {
        "amount": 5,
        "unit": "minutes"
      },
      "id": "c79b030b-30e0-43e2-8ec4-98294aa8d852",
      "name": "One final result wait",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        4440,
        680
      ],
      "webhookId": "46cac028-b861-4afc-8c5b-14e34e2f0e4c"
    },
    {
      "parameters": {
        "resource": "aiAgent",
        "operation": "getCallResult",
        "callId": "={{ $('Remember accepted call').item.json.call_id }}"
      },
      "id": "d2892fae-f856-4690-8ead-ed9ccb3c5b81",
      "name": "Read call result again",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [
        4680,
        680
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "function classifyResult(result, context, kind) {\n\tconst final = [\n\t\t'completed',\n\t\t'no_answer',\n\t\t'busy',\n\t\t'voicemail',\n\t\t'failed',\n\t\t'cancelled',\n\t\t'expired',\n\t].includes(result.status);\n\tconst analysisReady = final && Boolean(result.outcome || result.summary);\n\tlet route = 'needs_review';\n\tif (!final) route = 'pending_manual_review';\n\telse if (['cancelled', 'expired'].includes(result.status)) route = 'never_dialed';\n\telse if (['no_answer', 'busy', 'voicemail', 'failed'].includes(result.status))\n\t\troute = 'unreached';\n\telse if (!analysisReady) route = 'analysis_pending';\n\telse if (kind === 'appointment')\n\t\troute =\n\t\t\tresult.outcome === 'confirmed'\n\t\t\t\t? 'confirmed'\n\t\t\t\t: result.outcome === 'cannot_attend'\n\t\t\t\t\t? 'cancelled_by_customer'\n\t\t\t\t\t: 'follow_up';\n\telse if (['meeting_booked', 'appointment_booked'].includes(result.outcome)) route = 'sales_ready';\n\telse if (['callback_requested', 'callback_scheduled'].includes(result.outcome))\n\t\troute = 'follow_up';\n\telse if (['not_interested', 'wrong_number'].includes(result.outcome)) route = 'closed';\n\tif (kind === 'invoice' && final && analysisReady) route = 'staff_review';\n\treturn {\n\t\t...context,\n\t\tcall_id: result.call_id || context.call_id || '',\n\t\tstatus: result.status || 'unresolved',\n\t\toutcome: result.outcome ?? '',\n\t\tsummary: result.summary ?? '',\n\t\tsentiment: result.sentiment ?? '',\n\t\textracted_data: result.extracted_data ?? {},\n\t\tappointment: result.appointment ?? null,\n\t\tanalysisReady,\n\t\troute,\n\t\tneedsAttention: !['confirmed', 'sales_ready', 'closed'].includes(route),\n\t\tnotification:\n\t\t\t'Ringee ' +\n\t\t\tkind +\n\t\t\t': ' +\n\t\t\troute +\n\t\t\t'. Record ' +\n\t\t\tString(context.recordId ?? '') +\n\t\t\t'. Call ' +\n\t\t\tString(result.call_id || context.call_id || '') +\n\t\t\t'. Review the conversation in Ringee.',\n\t};\n}\nreturn $input.all().map((item,index)=>({json:classifyResult(item.json,$('Remember accepted call').item.json,\"callback\"),pairedItem:{item:index}}));"
      },
      "id": "1c485074-9f64-40a9-8288-ec0ce73bbb9a",
      "name": "Business result",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        4940,
        300
      ]
    },
    {
      "parameters": {
        "resource": "sheet",
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "options": {
          "cellFormat": "RAW",
          "useAppend": true
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "recordId": "={{ $('Business result').item.json.recordId }}",
            "callKey": "={{ $('Business result').item.json.callKey }}",
            "call_id": "={{ $('Business result').item.json.call_id }}",
            "status": "={{ $('Business result').item.json.status }}",
            "outcome": "={{ $('Business result').item.json.outcome }}",
            "summary": "={{ $('Business result').item.json.summary }}",
            "sentiment": "={{ $('Business result').item.json.sentiment }}",
            "route": "={{ $('Business result').item.json.route }}",
            "attemptCount": 1
          },
          "matchingColumns": [
            "recordId"
          ],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "id": "cfee36e1-036e-4a9e-8c73-11290808aae8",
      "name": "Save actual call result",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        5180,
        300
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "message",
        "operation": "post",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "text": "={{ $('Business result').item.json.notification }}",
        "otherOptions": {
          "includeLinkToWorkflow": false
        }
      },
      "id": "02d2afd9-505e-46c6-8825-47b6f13f0939",
      "name": "Notify the responsible team",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.7,
      "position": [
        6900,
        300
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "amount": 2,
        "unit": "seconds"
      },
      "id": "b6dda0bb-c5a9-4a22-8391-fbd40dff7ccd",
      "name": "Pace the next record",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        7140,
        300
      ],
      "webhookId": "072eb6fc-f9e7-4101-8b40-02813012c0a5"
    },
    {
      "parameters": {
        "content": "## Reconcile accepted work\nWithdraw a queued call before it drifts outside the calling window. Read delayed results with the existing call ID. Neither branch starts another call.",
        "width": 1500,
        "height": 370,
        "color": 7
      },
      "id": "2258e103-8257-457f-89ee-83ab593b6e74",
      "name": "Queued and delayed results",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        3440,
        600
      ]
    },
    {
      "id": "943e4286-290a-4796-84c2-511e45a74dbb",
      "name": "Hold this record and continue",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        520,
        2200
      ],
      "parameters": {}
    },
    {
      "id": "6416339e-5270-4893-8408-f84fe88325e8",
      "name": "Reconcile failed withdrawal",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [
        920,
        2200
      ],
      "parameters": {
        "resource": "aiAgent",
        "operation": "getCallStatus",
        "callId": "={{ $('Remember accepted call').item.json.call_id }}"
      },
      "onError": "continueErrorOutput"
    },
    {
      "id": "bb787792-6e83-4c28-81df-a73cd72a99a4",
      "name": "Require resolved withdrawal",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1320,
        2200
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const row=$input.first().json; if (!row.status || row.status==='queued') throw new Error('Withdrawal is unconfirmed and the original call can still dispatch. Reconcile its call ID immediately; never start another call.'); return $input.all();"
      }
    },
    {
      "id": "4c5c0a11-373e-42b8-87a5-1a2e55bacbe6",
      "name": "Read Ringee queue policy",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.5,
      "position": [
        1720,
        2200
      ],
      "parameters": {
        "method": "GET",
        "url": "https://api.ringee.io/api/v1/capabilities",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "ringeeApi",
        "options": {
          "redirect": {
            "redirect": {
              "followRedirects": false
            }
          },
          "timeout": 10000
        }
      },
      "onError": "continueErrorOutput"
    },
    {
      "id": "677bf831-4691-45e7-893b-edb260c583bb",
      "name": "Require immediate dispatch support",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2120,
        2200
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const c=$input.first().json; if(c.apiVersion!==1 || c.capabilities?.idempotentCalls!==true || c.capabilities?.queuedCalls!==false) throw new Error('This calling template requires a queue-disabled Ringee Cloud deployment. The published node cannot enforce a recipient-window dispatch deadline. No call was submitted.'); return [{json:$('Recheck hours before dialing').item.json}];"
      }
    }
  ],
  "connections": {
    "Missed inbound call": {
      "main": [
        [
          {
            "node": "Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read missed call": {
      "main": [
        [
          {
            "node": "Find the Ringee contact",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configuration": {
      "main": [
        [
          {
            "node": "Read missed call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find the Ringee contact": {
      "main": [
        [
          {
            "node": "Read existing callback permission",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read existing callback permission": {
      "main": [
        [
          {
            "node": "Normalize and check eligibility",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize and check eligibility": {
      "main": [
        [
          {
            "node": "Eligible for one authorized call?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Eligible for one authorized call?": {
      "main": [
        [
          {
            "node": "Process one record",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Held for manual review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process one record": {
      "main": [
        [],
        [
          {
            "node": "Recheck hours before dialing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recheck hours before dialing": {
      "main": [
        [
          {
            "node": "Still eligible now?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Still eligible now?": {
      "main": [
        [
          {
            "node": "Read Ringee queue policy",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Hold this record and continue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create or update Ringee contact": {
      "main": [
        [
          {
            "node": "Start authorized call",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start authorized call": {
      "main": [
        [
          {
            "node": "Remember accepted call",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remember accepted call": {
      "main": [
        [
          {
            "node": "Was the call queued?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Withdraw queued call": {
      "main": [
        [
          {
            "node": "Wait for call completion",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reconcile failed withdrawal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Was the call queued?": {
      "main": [
        [
          {
            "node": "Withdraw queued call",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for call completion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read call result": {
      "main": [
        [
          {
            "node": "Final status and analysis?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "One final result wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for call completion": {
      "main": [
        [
          {
            "node": "Read call result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Final status and analysis?": {
      "main": [
        [
          {
            "node": "Business result",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "One final result wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read call result again": {
      "main": [
        [
          {
            "node": "Business result",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "One final result wait": {
      "main": [
        [
          {
            "node": "Read call result again",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save actual call result": {
      "main": [
        [
          {
            "node": "Notify the responsible team",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Business result": {
      "main": [
        [
          {
            "node": "Save actual call result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify the responsible team": {
      "main": [
        [
          {
            "node": "Pace the next record",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pace the next record": {
      "main": [
        [
          {
            "node": "Process one record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hold this record and continue": {
      "main": [
        [
          {
            "node": "Process one record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reconcile failed withdrawal": {
      "main": [
        [
          {
            "node": "Require resolved withdrawal",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Require resolved withdrawal": {
      "main": [
        [
          {
            "node": "Wait for call completion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Ringee queue policy": {
      "main": [
        [
          {
            "node": "Require immediate dispatch support",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failure requires reconciliation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Require immediate dispatch support": {
      "main": [
        [
          {
            "node": "Create or update Ringee contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "executionTimeout": 3600
  },
  "pinData": {},
  "tags": []
}
