Lukas Narus
04/03/2025, 10:26 AMyaml
2. Inform the customer: "Ok, so I am sending the code to your email right now.".
- Trigger the 'send_email' function.
- <wait for 'send_email' result>
- Proceed to step 3.
Function:
js
{
type: 'function',
messages: [
{
type: 'request-complete',
content: `It was sent! The code you can use is ${pronouncation}.`,
},
{
type: 'request-failed',
content: `Ah, I couldn't send the email right now. The code you can use is ${pronouncation}.`,
},
{
type: 'request-response-delayed',
content: `um give me a sec`,
timingMilliseconds: 2000,
},
],
function: {
name: 'send_email',
description: 'Sends an email with the code to the customer.',
},
async: false,
server: {
url: `${env.PUBLIC_URL}/email`,
},
},
How can I make the tool call reliable? I've tried making it async: true, but it did not helpVapi Support Bot
04/03/2025, 10:28 AMjs
const assistant = {
monitorPlan: {
listenEnabled: true,
controlEnabled: true
}
};
This will help you see what's happening during the call and identify potential issues.
### 6. Model Temperature
Consider setting a lower temperature (0-0.3) for more predictable responses, as suggested in [community discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341892594044633099).
Is there anything specific about these suggestions you'd like me to elaborate on?
Sources:
- [https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336440478727667844](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336440478727667844)
- [https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341835360094785587](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341835360094785587)
- [https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1325000684231196775](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1325000684231196775)
- [https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1340737584309211136](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1340737584309211136)
- [https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341892594044633099](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341892594044633099)Vapi Support Bot
04/03/2025, 10:28 AMsend_email tool call in your conversation flow.
I'm unable to diagnose the specific issue with your server implementation at ${env.PUBLIC_URL}/email, but I can definitely help with several approaches to improve the reliability of your tool calls.
Here are some strategies to make your OpenAI tool calls more reliable:
### 1. Model Selection
Consider using a more stable model for production. According to [community discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336440478727667844), it's recommended to "use GPT-4o for production and realtime for development/testing" as the realtime model may be less stable.
### 2. Tool Configuration Adjustments
Try these configuration changes:
js
{
type: 'function',
messages: [], // Set empty messages array to prevent default messages
function: {
name: 'send_email',
description: 'Sends an email with the code to the customer.',
},
async: false, // Keep synchronous
blocking: true, // Add this to ensure it waits for completion
server: {
url: `${env.PUBLIC_URL}/email`,
},
}
Setting blocking: true will make the tool call wait for the onComplete callback after the message is spoken before proceeding, which may help with reliability.
### 3. Prompt Engineering
Modify your conversation flow to explicitly instruct the LLM to call the tool:
yaml
2. Inform the customer: "Ok, so I am sending the code to your email right now. I will now use the send_email tool to send you the code."
- Trigger the 'send_email' function.
- <wait for 'send_email' result>
- Proceed to step 3.
### 4. Response Format
Ensure your server is returning the correct JSON format that Vapi expects:
json
{
"results": [{
"toolCallId": "dynamically_replace_with_actual_id",
"result": "Email sent successfully with code XYZ"
}]
}Bharath
04/06/2025, 11:48 AMBharath
04/06/2025, 11:54 AMLukas Narus
04/07/2025, 11:34 AMBharath
04/08/2025, 10:02 PMLukas Narus
04/09/2025, 12:01 PMf4fe2b4c-1359-4cd1-875e-095931bfbf27
So it said this twice in the call "Ok, so I am sending the code to your email right now." at 15:49:05:119 and 15:49:08:190
It should've called send_email function both times, but it did not do that even a single timeBharath
04/11/2025, 9:07 PM"Ok, so I am sending the code to your email right now. and Trigger the 'send_email' function