> For the complete documentation index, see [llms.txt](https://project-44.gitbook.io/retell-ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://project-44.gitbook.io/retell-ai/build/handle-voicemail.md).

# Handle voicemail

Configure your AI agent to detect and handle voicemails automatically

It is common that your phone agent will encounter voicemails. You can configure your agent to either hang up or leave a message when it detects a voicemail.

The system internally run voicemail detection continuously (within the timeout), and if you select to hang up in voicemail, we will do that the moment we detect we are in voicemail. If you select to leave a message, the system will wait for its turn to speak to leave that message. If the voicemail detection timeout is reached, the system will stop the voicemail detection, and will continue with the call as normal.

![Voicemail settings](https://mintlify.s3.us-west-1.amazonaws.com/retellai/images/voicemail.png)1

Enable Voicemail Detection

Navigate to your agent settings and enable “Voicemail Detection”

2

Choose Voicemail Behavior

Select one of two options:

* **Hang up**: The agent will disconnect when it detects a voicemail
* **Leave a message**: The agent will play a pre-recorded message after it’s agent’s turn to speak

3

Configure Detection Duration

Set the “Voicemail Detection Duration” timeout. This is the time where you will have the voicemail detection to be active for after the call is connected. With more minutes into the call, the chance you hit a voicemail is lower and you might want to turn the voicemail detection off to avoid false positives, and that’s why there’s a timeout setting here. This timeout will not cause your agent’s voicemail message to be cut off.

We recommend starting with 30 seconds, and extend this time if you reach voicemail in a later time in the call or the recorded message in that voicemail is long.

4

Set Voicemail Message (Optional)

If you selected “Leave a message” in Step 2: Enter the message you want the agent to leave. You can either set a prompt so that the message will be generated dynamically, or you can set a fixed static message.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://project-44.gitbook.io/retell-ai/build/handle-voicemail.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
