Skip to content

Instantly share code, notes, and snippets.

@hmseeb
Last active March 10, 2026 20:58
Show Gist options
  • Select an option

  • Save hmseeb/2671607ad9185ebb7543ee18fe78b614 to your computer and use it in GitHub Desktop.

Select an option

Save hmseeb/2671607ad9185ebb7543ee18fe78b614 to your computer and use it in GitHub Desktop.

What we're building

We have a Retell AI voice agent that creates cases in IRS Logics CRM through a Supabase edge function. Currently, the edge function extracts caller_name, caller_phone, and estimated_tax_debt from the Retell function call and creates a case.

We need to also capture the Retell call_id so we can later link the call recording URL to the case (handled separately via n8n post-call webhook).

How Retell sends the payload

When Retell triggers a custom function, it sends a POST request to our edge function with this structure:

{
  "name": "generate_case_number",
  "call": {
    "call_id": "call_abc123...",
    "// other call context like transcript, etc."
  },
  "args": {
    "caller_name": "John Smith",
    "caller_phone": "+15551234567",
    "estimated_tax_debt": 15000
  }
}

Important: The call_id is inside the call object, NOT at the top level and NOT inside args.

Changes needed

1. Supabase cases table — add call_id column

  • Add a new nullable text column call_id to the cases table
  • This stores the Retell call ID (e.g., "call_abc123...")

2. Edge function — extract call_id from the call object

Update the edge function to extract call_id from the Retell payload like this:

const { name, call, args } = await req.json();
const call_id = call.call_id;
const { caller_name, caller_phone, estimated_tax_debt } = args;

Then include call_id when inserting into the cases table.

Summary of changes:

  1. Add call_id (text, nullable) column to cases table
  2. In the edge function, extract call_id from call.call_id in the request body
  3. Include call_id when inserting into the cases table
  4. Do NOT change anything else — the Logics CRM API call, response format, and existing fields should remain exactly the same
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment