endCall when voicemail is detected
# support
s
How can I instruct my prompt assistant to end the call when a voicemail is detected?
v
Hi there! 👋 I'd be happy to help you set up your prompt assistant to end calls when voicemail is detected. I can definitely help you with configuring your prompt assistant to automatically end calls when voicemail is detected in Vapi. To instruct your prompt assistant to end the call when voicemail is detected, you'll need to: 1. Enable voicemail detection - According to the [Vapi documentation](https://docs.vapi.ai/phone-calling/voice-mail-detection), you have two methods for detecting voicemail: - Using Twilio's built-in detection - Using Vapi's built-in LLM-powered tool - For best results, enable both methods simultaneously 2. Configure voicemail detection settings - Here's an example configuration:
Copy code
json
   "voicemailDetection": {
     "provider": "twilio",
     "voicemailDetectionTypes": [
       "machine_end_beep",
       "machine_end_silence",
       "human",
       "fax",
       "unknown",
       "machine_end_other"
     ],
     "enabled": true,
     "machineDetectionTimeout": 45,
     "machineDetectionSpeechThreshold": 2400,
     "machineDetectionSpeechEndThreshold": 2400,
     "machineDetectionSilenceTimeout": 6000
   }
3. Include the endCall tool in your assistant configuration - Add the
endCall
tool to your assistant's available tools:
Copy code
json
   {
     "model": {
       "provider": "openai",
       "model": "gpt-3.5-turbo",
       "messages": [
         {
           "role": "system",
           "content": "You are an assistant. When voicemail is detected, use the endCall function."
         }
       ],
       "tools": [
         {
           "type": "endCall"
         }
       ]
     }
   }
4. Update your system prompt - Modify your assistant's system prompt to include instructions for handling voicemail detection. For example: ```
You are an assistant. Monitor the call for signs of voicemail. If you detect that the call has reached a voicemail system, immediately use the endCall tool to end the call. Signs of voicemail include greetings like "Please leave a message after the tone" or "You've reached the voicemail of..."
Copy code
5. **Enable Vapi's built-in voicemail tool** - Add the voicemail tool to your model configuration:
   ```json
   "tools": [
     { "type": "voicemail" },
     { "type": "endCall" }
   ]
When voicemail is detected, your assistant will trigger the
endCall
tool based on your system prompt instructions. Is there anything specific about this setup you'd like me to explain in more detail? Source: - [Vapi documentation](https://docs.vapi.ai/phone-calling/voice-mail-detection)
p
when a voicemail is detected using existing tools, it first tries to leave a voicemail message if it's not empty. Then, these tools will end the call by themselves.
5 Views