{
  "nodes": [
    {
      "id": "9a8d7d07-a1b3-4bca-8e77-10da3a2abc45",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -160,
        0
      ],
      "parameters": {
        "path": "retell-dynamic-variables",
        "options": {
          "ipWhitelist": "100.20.5.228"
        },
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "79e77d72-6e13-428c-ad10-58e6930e2d90",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        440,
        0
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={\n  \"call_inbound\": {\n    \"dynamic_variables\": {\n        \"first_name\": \"{{ $json['First Name'] }}\",\n        \"last_name\": \"{{ $json['Last name'] }}\",\n        \"email\": \"{{ $json['E-Mail'] }}\",\n        \"variable_1\": \"{{ $json['User Variable 1'] }}\",\n        \"variable_2\": \"{{ $json['User Variable 2']}}\"\n    },\n    \"metadata\": {\n    }\n  }\n}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "10919781-9750-417f-bba6-293bf99dbc3e",
      "name": "Get user in DB by Phone Number",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        140,
        0
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.body.call_inbound.from_number }}",
              "lookupColumn": "Phone Number"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "REPLACE_WITH_RESOURCE"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "REPLACE_WITH_RESOURCE"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "de9a2ff5-690e-4e1e-ab5c-5a8825986871",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -440
      ],
      "parameters": {
        "color": 7,
        "width": 601,
        "height": 1105,
        "content": "## Handle Retell's Inbound call webhooks\n\n## Overview\n- This workflow provides Retell agent builders with a simple way to populate [dynamic variables](https://docs.retellai.com/build/dynamic-variables) using n8n.\n- The workflow fetches user information from a Google Sheet based on the phone number and sends it back to Retell.\n- It is based on Retell's [Inbound Webhook Call](https://docs.retellai.com/features/inbound-call-webhook).\n- Retell is a service that lets you create Voice Agents that handle voice calls simply, based on a prompt or using a conversational flow builder.\n\n## Prerequisites\n- Have a [Retell AI Account](https://www.retellai.com/)\n- [Create a Retell agent](https://docs.retellai.com/get-started/quick-start)\n- [Purchase a phone number](https://docs.retellai.com/deploy/purchase-number) and associate it with your agent\n- Create a Google Sheets - for example, [make a copy of this one](https://docs.google.com/spreadsheets/d/REPLACE_WITH_DOCUMENT_ID/edit?usp=sharing).\n- Your Google Sheet must have at least one column with the phone number. The remaining columns will be used to populate your Retell agent’s dynamic variables.\n- All fields are returned as strings to Retell (variables are replaced as text)\n\n## How it works\n- The webhook call is received from Retell. We filter the call using their whitelisted IP address.\n- It extracts data from the webhook call and uses it to retrieve the user from Google Sheets.\n- It formats the data in the response to match Retell's expected format.\n- Retell uses this data to replace [dynamic variables](https://docs.retellai.com/build/dynamic-variables#dynamic-variables) in the prompts.\n\n\n## How to use it\nSee the description for screenshots!\n- Set the webhook name (keep it as POST).\n- Copy the Webhook URL (e.g., `https://example.invalid/REPLACE_WITH_N8N_ENDPOINT and paste it into Retell's interface. Navigate to \"Phone Numbers\", click on the phone number, and enable \"Add an inbound webhook\".\n- In your prompt (e.g., \"welcome message\"), use the variable with this syntax: `{{variable_name}}` (see [Retell's documentation](https://docs.retellai.com/build/dynamic-variables)).\n- These variables will be dynamically replaced by the data in your Google Sheet.\n\n\n## Notes\n- In Google Sheets, the phone number must start with `'+'`.\n- Phone numbers must be formatted like the example: with the `+`, extension, and no spaces.\n- You can use any database—just replace Google Sheets with your own, making sure to keep the phone number formatting consistent.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "55b087bf-d51f-4660-94c7-3742915ff79b",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        -120
      ],
      "parameters": {
        "color": 5,
        "width": 220,
        "height": 300,
        "content": "Change the path if needed"
      },
      "typeVersion": 1
    },
    {
      "id": "bd6a7c81-5125-4f46-a1ba-86029d3a0eda",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -120
      ],
      "parameters": {
        "color": 5,
        "width": 220,
        "height": 300,
        "content": "Replace with your own Google Sheets, including the dynamic variables of your Retell Agent"
      },
      "typeVersion": 1
    },
    {
      "id": "7105c832-ffbe-4d36-90ec-b8c868388c4e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        -120
      ],
      "parameters": {
        "color": 5,
        "width": 220,
        "height": 300,
        "content": "Adapt the response to match your Retell dynamic variables"
      },
      "typeVersion": 1
    },
    {
      "id": "2bf08311-87fd-5258-bc92-b7efece69ed4",
      "name": "Publication · Overview and setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1680,
        -440
      ],
      "parameters": {
        "content": "# Handle Retell's Inbound call webhooks\n\n## Purpose and structure\nThis folder contains the **Handle Retell's Inbound call webhooks** workflow. Its executable nodes use `googleSheets`, `respondToWebhook`, `webhook`. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.\n\n## Setup\nImport inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.\n\n## Entry points\nWebhook\n\n## Verification\nSanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.\n\n## Attribution\nhttps://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Googlesheets/0818_GoogleSheets_Respondtowebhook_Import_Webhook.json\nMIT; preserve source notices.",
        "width": 700,
        "height": 800,
        "color": 1
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Get user in DB by Phone Number",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get user in DB by Phone Number": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false
}
