“I have a Retell.ai voice agent that fires a call_analyzed webhook to n8n. The customer data arrives correctly in the webhook payload at this exact path:
body.call.call_analysis.custom_analysis_data._first__name
body.call.call_analysis.custom_analysis_data._last__name
body.call.call_analysis.custom_analysis_data._phone_number
body.call.call_analysis.custom_analysis_data._address
body.call.call_analysis.custom_analysis_data._email
My Code node uses $input.first().json.body.call but keeps outputting ‘Not Provided’. The workflow is active and the webhook is receiving data. Need help mapping these fields correctly and then POSTing them to the Responsibid create lead API endpoint.”
Hi @Brian_Gilligan Welcome!
This can occur when you are not currently using the nested path from the webhook URL item into your code node, consider something similar to this:
const item = $input.first().json;
const data = item.body.call.call_analysis.custom_analysis_data;
return [{
json: {
first_name: data._first__name,
last_name: data._last__name,
phone: data._phone_number,
address: data._address,
email: data._email,
}
}];
and then you can map the fields into your HTTP node directly
the code above looks solid. only thing id add: check if call_analysis exists before accessing custom_analysis_data, since Retell webhooks can omit fields on error calls. something like:
const data = item.body?.call?.call_analysis?.custom_analysis_data;
if (!data) throw new Error('Missing analysis data');
saves debugging time when a webhook arrives without the expected fields.
The code above looks solid — the one thing I’d add is checking if call_analysis exists before diving into custom_analysis_data, since Retell webhooks can sometimes omit fields on error calls. Something like: const data = item.body?.call?.call_analysis?.custom_analysis_data; if (!data) throw new Error('Missing analysis data'); — saves debugging time if a webhook arrives incomplete.
The code above looks solid — the one thing I’d add is checking if call_analysis exists before diving into custom_analysis_data, since Retell webhooks can sometimes omit fields on error calls. Something like: const data = item.body?.call?.call_analysis?.custom_analysis_data; if (!data) throw new Error('Missing analysis data'); — saves debugging time if a webhook arrives incomplete.