{
  "name": "Call back missed calls automatically with a Ringee AI voice agent",
  "nodes": [
    {
      "parameters": {
        "content": "## Missed call callback\nWhen someone calls your Ringee number and nobody answers, an AI voice agent calls them back a few minutes later, and every callback is logged in a Google Sheet.\n\nA caller is called back **once per four-hour window**: the Idempotency Key is their number and the window their missed call fell in, so a repeated or late-retried event never calls twice.\n\n[Ringee](https://ringee.io) · [Docs](https://docs.ringee.io)",
        "height": 250,
        "width": 470,
        "color": 4
      },
      "id": "d22a8a38-936a-5ded-93e6-6a93d506e24c",
      "name": "About this workflow",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-260, -300]
    },
    {
      "parameters": {
        "content": "**Before you run this**\n1. In Ringee, create a **Custom Integration** (Integrations → Custom Integrations) and copy its **API key** and **Signing Secret**.\n2. In n8n, create a **Ringee API** credential with both.\n3. Pick your AI voice agent in the Ringee node.\n4. Activate the workflow, then paste the **Ringee Trigger's Production URL** into the integration's **Outbound URL** and tick *Call Missed*.\n\nUse an **Appointment Booking** agent. Create a sheet **Callback log** with columns `Time`, `Caller`, `Our number`, `Callback call`, `Reason`, `Status`. Each callback has one row, found again by `Callback call`; `Status` says whether Ringee placed it or queued it for when there is capacity.\n\n**Callbacks are limited.** Each number is called back at most once in each four-hour window, counted from when the missed call happened, so a caller who rings ten times is not called ten times, and two Ringee numbers running this workflow cannot call each other back forever.",
        "height": 470,
        "width": 470,
        "color": 5
      },
      "id": "e6ccaca0-9fa4-5bd1-9999-ecbf9ce1df0f",
      "name": "Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-260, -50]
    },
    {
      "parameters": {
        "content": "**Consent**\nThe person phoned you first, which usually allows one callback. Check your local rules about calling back, and keep calls inside reasonable hours: the *Wait* node below delays the call, and you can add a time check before it.",
        "height": 190,
        "width": 400,
        "color": 3
      },
      "id": "4184da7e-f71d-5979-92fa-3bef87cbffab",
      "name": "Consent",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [260, -300]
    },
    {
      "parameters": {
        "events": ["call.missed"],
        "options": {}
      },
      "id": "31f2530e-bf13-5e9d-94fb-c36355f106ee",
      "name": "Missed call",
      "type": "n8n-nodes-ringee.ringeeTrigger",
      "typeVersion": 1,
      "position": [260, -40],
      "webhookId": "3e29fb2f-c4e9-5f04-95ee-97e89308a208"
    },
    {
      "parameters": {
        "amount": 5,
        "unit": "minutes"
      },
      "id": "66030103-2dc9-5b62-ab19-a19cd88225c1",
      "name": "Wait 5 minutes",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [500, -40],
      "webhookId": "f54f3a01-34b4-58ca-a67c-e6ea82a0f735"
    },
    {
      "parameters": {
        "resource": "aiAgent",
        "operation": "startCall",
        "agentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "phoneNumber": "={{ $('Missed call').item.json.data.fromNumber }}",
        "variables": {
          "mappingMode": "defineBelow",
          "value": {
            "first_name": "there",
            "reason": "You called us a few minutes ago and we missed your call"
          },
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "externalId": "={{ 'callback-' + $('Missed call').item.json.data.callId }}",
          "idempotencyKey": "={{ 'callback-' + String($('Missed call').item.json.data.fromNumber).replace(/[^\\d+]/g, '') + '-' + Math.floor((Date.parse($('Missed call').item.json.data.occurredAt || $('Missed call').item.json.occurredAt) || $now.toMillis()) / 14400000) }}"
        }
      },
      "id": "e2056cae-eb4a-503f-9ee9-5c4af730f995",
      "name": "Call them back",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [740, -40]
    },
    {
      "parameters": {
        "resource": "sheet",
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Time": "={{ $('Missed call').item.json.occurredAt }}",
            "Caller": "={{ $('Missed call').item.json.data.fromNumber }}",
            "Our number": "={{ $('Missed call').item.json.data.toNumber }}",
            "Callback call": "={{ $json.call_id }}",
            "Reason": "={{ $('Missed call').item.json.data.reason || 'Not answered' }}",
            "Status": "={{ $json.status === 'queued' ? 'Queued' : 'Placed' }}"
          },
          "matchingColumns": ["Callback call"],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "id": "7c13d79a-6d57-5133-b112-a4067acc2bc1",
      "name": "Log the callback",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [980, -40],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "18ac81d4-c3a7-4f67-b0bf-e8e4ac60fd8b",
              "leftValue": "={{ $json.status }}",
              "rightValue": "queued",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "45ccde07-1032-4213-b1cd-d6b9bcb97a03",
      "name": "Was the operation queued?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [260, 320]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "fa3d6d07-eb2a-47ad-b95f-9866593afb0a",
              "name": "call_id",
              "value": "={{ $json.call_id }}",
              "type": "string"
            },
            {
              "id": "d9287e4f-990e-4771-a6a9-13d17b3903ac",
              "name": "expires_at",
              "value": "={{ $json.expires_at || '' }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "e6cc7d19-e430-44c0-8122-ef4a020e0313",
      "name": "Remember queued operation",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [480, 320]
    },
    {
      "parameters": {
        "amount": "={{ Math.max(1, Math.min(86401, Math.ceil((Math.max(Date.now(), ...$input.all().map(item => Date.parse(item.json.expires_at || '') || Date.now())) - Date.now()) / 1000) + 1)) }}",
        "unit": "seconds"
      },
      "id": "0a582daa-9169-43cc-8e65-5595f00b27c3",
      "name": "Wait until queue deadline",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [700, 320],
      "webhookId": "cd5e0607-7a88-49b4-93af-d0b93985650d"
    },
    {
      "parameters": {
        "resource": "aiAgent",
        "operation": "getCallStatus",
        "callId": "={{ $json.call_id }}"
      },
      "id": "3a79feec-c330-42c5-9676-a271468601b3",
      "name": "Check queued call status",
      "type": "n8n-nodes-ringee.ringee",
      "typeVersion": 1,
      "position": [920, 320],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6fc06d20-e039-464d-87ab-4530dfbcc0a0",
              "name": "call_id",
              "value": "={{ $json.call_id || $('Remember queued operation').item.json.call_id }}",
              "type": "string"
            },
            {
              "id": "ece46c73-e917-4881-a2e6-2f36d2467f47",
              "name": "expires_at",
              "value": "={{ $('Remember queued operation').item.json.expires_at }}",
              "type": "string"
            },
            {
              "id": "b6baee2c-74eb-4faf-bca1-7891d5aa67a2",
              "name": "status",
              "value": "={{ $json.status || 'unresolved' }}",
              "type": "string"
            },
            {
              "id": "617e5071-598a-4dd9-9a5f-2c8b8c6940ea",
              "name": "queue_check",
              "value": "={{ ['cancelled', 'expired'].includes($json.status) ? 'never_dialed' : $json.status === 'failed' ? 'failed' : ['completed', 'no_answer', 'busy', 'voicemail'].includes($json.status) ? 'ended_see_result_or_event' : 'unresolved_inspect_ringee' }}",
              "type": "string"
            },
            {
              "id": "63a4abf0-87d1-4e8f-bbc1-e65abdbb13f5",
              "name": "needs_attention",
              "value": "={{ !['completed', 'no_answer', 'busy', 'voicemail'].includes($json.status) }}",
              "type": "boolean"
            }
          ]
        },
        "options": {}
      },
      "id": "711a93ed-5a48-4d9e-8b29-267b053a8ab2",
      "name": "Queue check: inspect attention items",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [1140, 320]
    },
    {
      "parameters": {
        "content": "## Queued calls need a status path\nSelect your Ringee credential on **Check queued call status** too. This branch saves the operation ID and deadline in execution data, waits until the latest deadline in this batch (at most 24 hours plus one second) and reads status once, with bounded read retries. Expired/cancelled calls never dial; failed or unresolved operations need inspection. **Queue check: inspect attention items** retains the ID and marks `needs_attention`. Connect that output to your own idempotent follow-up if required. It does not create a call, retry Start Call, or write a second CRM result. The existing event/result branch still handles dialed calls. n8n runs the branches that leave one node from top to bottom and stops the whole run at the first node that fails. **Log the callback** therefore continues on its error output, so a failed log write never prevents this check. No event is expected for an operation that never dialed. Preserve n8n execution/Wait data and configure error notifications before production use.\n\n[Queue documentation](https://github.com/ringee-io/n8n-nodes-ringee/blob/main/docs/queue-and-capacity.md)",
        "height": 420,
        "width": 590,
        "color": 5
      },
      "id": "958661e1-6794-4fd5-a1ea-383278bffedc",
      "name": "Queued operations can end without an event",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-380, 320]
    },
    {
      "parameters": {},
      "id": "bb805d2b-24a2-5b7c-902b-a58b1b9da442",
      "name": "Callback not logged: see the error",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [1220, 120]
    }
  ],
  "connections": {
    "Missed call": {
      "main": [
        [
          {
            "node": "Wait 5 minutes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 5 minutes": {
      "main": [
        [
          {
            "node": "Call them back",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call them back": {
      "main": [
        [
          {
            "node": "Log the callback",
            "type": "main",
            "index": 0
          },
          {
            "node": "Was the operation queued?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Was the operation queued?": {
      "main": [
        [
          {
            "node": "Remember queued operation",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Remember queued operation": {
      "main": [
        [
          {
            "node": "Wait until queue deadline",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait until queue deadline": {
      "main": [
        [
          {
            "node": "Check queued call status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check queued call status": {
      "main": [
        [
          {
            "node": "Queue check: inspect attention items",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Queue check: inspect attention items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log the callback": {
      "main": [
        [],
        [
          {
            "node": "Callback not logged: see the error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {
    "Missed call": [
      {
        "json": {
          "event": "call.missed",
          "eventId": "evt_sample_0003",
          "occurredAt": "2026-11-24T15:10:00.000Z",
          "workspaceId": "org_sample",
          "integrationId": "ci_sample",
          "data": {
            "callId": "6f1c2d3e-0000-4000-8000-000000000009",
            "fromNumber": "+14155550123",
            "toNumber": "+14155550100",
            "occurredAt": "2026-11-24T15:10:00.000Z",
            "reason": "No one answered"
          }
        }
      }
    ]
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "e8174469-d6bb-5219-83ea-d4da030151d0",
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "ringee-n8n-template"
  },
  "tags": []
}
