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).
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.
- Add a new nullable text column
call_idto thecasestable - This stores the Retell call ID (e.g., "call_abc123...")
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.
- Add
call_id(text, nullable) column tocasestable - In the edge function, extract
call_idfromcall.call_idin the request body - Include
call_idwhen inserting into thecasestable - Do NOT change anything else — the Logics CRM API call, response format, and existing fields should remain exactly the same