https://retellai.com/?utm_source=discord&utm_medium=seo logo
when retell ai runs a function , it takes 15 secon...
# ❓・ai-evy-support
k
@AI Evy @support_29992 when retell ai runs a function , it takes 15 seconds for function to return the result from n8n , meanwhile if caller says anything like thank you or are you there , ai inturrepts the function and immideately comes back with fabricated result instead of waiting for n8n to send the result , how to fix it
a
Thanks for tagging me @kartik_72139. I'll look through relevant sources and get back to you shortly.
### Answer Based on the available documentation, when implementing custom functions with Retell AI, there are specific timeout and execution behaviors to be aware of. The request will timeout in your specified timeout period, or 2 minutes if not specified [(1) ]() [(2) ]() . When a request fails, it will be retried up to 2 times . To handle longer-running functions effectively, you should include an
execution_message
parameter in your custom function definition [(1) ]() . This message is what the agent says to the user while the function is executing [(3) ](

▾

) . For example, you can configure your function to say "One moment, I'm booking your appointment" while waiting for the n8n workflow to complete . Here's how to structure this in your function definition - the parameter should include a message field:
Copy code
json
{
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "The message you will say while setting up the appointments"
    }
  }
}
[(4) ]() However, the documentation doesn't explicitly address how to prevent the AI from responding to user interjections during function execution. The current behavior you're experiencing—where the AI responds to user input like "thank you" or "are you there" before the function completes—isn't covered in the available sources. For your specific 15-second n8n delay issue, I recommend: - Verifying your n8n webhook is configured to "respond to webhook" (not "immediately") [(5) ]() - Ensuring your function timeout is set appropriately to accommodate the 15-second execution time [(1) ]() [(2) ]() - Using the
execution_message
parameter to keep users informed during the wait [(1) ]() [(3) ](

▾

) If you need more specific guidance on preventing AI interruptions during function execution, you may want to reach out to support: - Visit [Contact Sales]() - Visit [) Would you like me to provide a general answer based on common conversational AI patterns for handling this scenario?
​ To learn more, see the sources I considered: [[1] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) [[2] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[3] Use Function Calling (Advanced) With Retell AI](

https://www.youtube.com/watch?v=w39kgzeaIxs▾

) [[4] Integrate Function Calling](https://docs.retellai.com/integrate-llm/integrate-function-calling) [[5] I’m integrating Retell AI with n8n using a custom function that checks for existing bookings](https://discord.com/channels/1186424376300679209/1425861757133520956) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
k
@AI Evy how do i implement sonic 3 and where do i find the emotive voices
a
Thanks for the follow-up, @kartik_72139. I'll get back to you soon.
### Answer I don't have information about implementing "Sonic 3" or finding "emotive voices" in the available Retell AI documentation sources. The sources I have access to focus on custom functions, function calling, and API integrations with Retell AI, but don't mention Sonic 3 or emotive voices specifically. For guidance on voice configuration and TTS (text-to-speech) options in Retell AI, I recommend: - Visit [Contact Sales]() - Visit [) Would you like me to provide a general answer about voice configuration options based on common voice AI patterns?
message has been deleted
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
k
@AI Evy the agent level webhook url gets trigerred 3 times during the events call_analyzed call_ended call_started , i want it to be rigerred only at call_ended , how to do it
a
Thanks for the follow-up, @kartik_72139. I'll get back to you soon.
### Answer When you set a webhook URL at the agent level in Retell AI, the webhook receives all three event types:
call_started
,
call_ended
, and
call_analyzed
[(1) ]() . To filter for only the
call_ended
event, you need to handle this filtering in your webhook endpoint code. Here's how to implement this:
Copy code
javascript
app.post("/webhook", (req: Request, res: Response) => {
 const {event, call} = req.body;
 switch (event) {
 case "call_started":
 console.log("Call started event received", call.call_id) ;
 break;
 case "call_ended":
 console.log("Call ended event received", call.call_id) ;
 break;
 case "call_analyzed":
 console.log("Call analyzed event received", call.call_id) ;
 break;
 default:
 console.log("Received an unknown event:", event) ;
 }
 // Acknowledge the receipt of the event
 res.status(204) .send() ;
}) ;
[(2) ]() In this code, you can see the webhook receives all events, and you use a switch statement to handle each event type differently . To process only
call_ended
events, you would modify this to only execute your logic when
event === "call_ended"
. The webhook URL you set at the agent level will receive all call events [(3) ]() [(4) ]() [(5) ]() . Retell AI expects a successful status code (2xx) to be returned, with no body expected [(1) ]() . If you want to completely avoid receiving the other events at your endpoint, the documentation doesn't provide a way to configure the webhook to send only specific event types. The filtering must be done in your webhook handler code. **
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
k
if webhook is set at n8n to receive data , where should i add this code and modify it to receive only call_ended data
@AI Evy if webhook is set at n8n to receive data , where should i add this code and modify it to receive only call_ended data
a
Thanks for the follow-up, @kartik_72139. I'll get back to you soon.
### Answer ### Answer When using n8n to receive webhook data from Retell AI, you need to add filtering logic within your n8n workflow rather than in external code [(1) ]() [(2) ]() . In n8n, after your Webhook node receives the data from Retell AI, add a Filter or Switch node to process only
call_ended
events. Here's how to set this up: 1. Add a Webhook node in n8n and use its production URL in your Retell AI agent-level webhook configuration [(3) ]() 2. Add a Switch node or IF node after the Webhook node 3. Configure the condition to check if the event type equals "call_ended" The condition should check: - **Field**:
{{ $json.event }}
- **Operation**: Equal to - **Value**:
call_ended
This filters the webhook payload so that only when
event
equals
"call_ended"
will the workflow continue to your next nodes [(1) ]() . Remember that Retell AI will still send all three event types (
call_started
,
call_ended
, and
call_analyzed
) to your webhook URL . The webhook has a timeout of 10 seconds and will retry up to 3 times if no success status (2xx) is received . Your n8n webhook must return a 2xx status code for all events, even if you're only processing
call_ended
. Make sure you're using the production webhook URL from n8n (not the test URL) , as the test URL only catches the first webhook [(3) ]() . **
​ To learn more, see the sources I considered: [[1] Webhook Overview](https://docs.retellai.com/features/webhook-overview) [[2] Setup guide](https://docs.retellai.com/features/register-webhook) [[3] Issue with end_call webhook not being received in N8N](https://discord.com/channels/1186424376300679209/1382070123661361295) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.