# Detecting Voicemail

## Callee Type Detection

When placing outbound calls, it is often necessary to alter the call flow based on the type of callee you have reached. For example you may wish to play a specific message in the case of an answering machine or proceed with the interactive call flow when you reach a person.

Fuse includes support for callee type detection through the global variable `session.connection.callee_type`.

The platform automatically updates this variable over the course of the first 4 seconds of the call. \
Initially the variable will contain the value “*processing*”, and after 4 seconds it will be updated to be one of the following values:

1. **voice**
2. **answeringmachine**
3. **fax**
4. **unknown**

The recommended approach for using this variable is to play an initial prompt that is at least 4 seconds long and then use the [*Compare Variable*](https://docs.plumvoice.com/fuse/call-flow/compare-variable) (<img src="https://820663326-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M40QJ5NXmtM4utV6bD_%2F-M4u8_YcRziLXQiLsKMa%2F-M4u9_-yddKq0elF-SOr%2Fbranch_on_var.svg?alt=media&#x26;token=7720daa8-6f90-4630-ae4a-b84db5d02d5f" alt="" data-size="line">) module to branch on the different values that *`session.connection.callee_type`*.

Here is an example of a module branching on the `session.connection.callee_type` value:

<div align="left"><img src="https://820663326-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M40QJ5NXmtM4utV6bD_%2F-M4u8_YcRziLXQiLsKMa%2F-M4u9_-CRZvKZe1zCU-S%2Foutbound_callee.png?alt=media&#x26;token=e6c5bcff-2ec9-439a-a612-4c35f5047fb0" alt=""></div>

### **Detecting Voicemail Call Flow Example**

While it is highly accurate, `session.connection.callee_type` is attempting to analyze potentially non-standard voicemail and answering machine behaviors, therefore, its performance is not guaranteed. It can and will have issues with certain types of voicemail or ring back behaviors that will lead to false positives/false negatives.

The best practice is for the initial prompt request the callee to press a button to accept the call, which guarantees that the call was connected to a person rather than a machine.

Consider the following example:

<div align="left"><img src="https://820663326-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M40QJ5NXmtM4utV6bD_%2F-M4u8_YcRziLXQiLsKMa%2F-M4u9_-FImhETFK7UYUz%2Foutbound_voicemail.png?alt=media&#x26;token=658da2b8-caed-4b99-925f-03c6f910f639" alt=""></div>

|                       | Person answers with DTMF                                                                                                                                                                                                    | Person answers by voice                                                                                                                                                                                              | Answering Machine                                                                                                                                         |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Call scenario**     | **Callee presses any key**                                                                                                                                                                                                  | **Callee answers by voice (such as&#x20;*****hi*****,&#x20;*****hello*****) but&#x20;*****not*****&#x20;by touch tone key**                                                                                          | **The call is directed to the answering machine**                                                                                                         |
| *welcome*             | The [record](https://docs.plumvoice.com/fuse/input/record) module is used to see if the callee respond to the welcome prompt, Any touch tone input on the will then end the record module and continue onto the next module | The record module is terminated by the [final silence](https://docs.plumvoice.com/fuse/module-settings#final-silence) setting in the record module                                                                   | The record module is terminated by the [final silence](https://docs.plumvoice.com/fuse/module-settings#final-silence) setting in the record module        |
| *check\_response*     | The *welcome$.termchar* value in the module will indicate that the recording is indeed terminated by a touch tone                                                                                                           | Since the recording ended by silence, *welcome$.termchar* is *false* and the application will branch to the right                                                                                                    | Since the recording ended by silence, *welcome$.termchar* is *false* and the application will branch to the right                                         |
| *check\_callee\_type* |                                                                                                                                                                                                                             | Because there was a response from the caller within the first 4 seconds of the call, the platform will evaluate *session.connection.callee\_type* as “*voice*” and therefore direct the application back to the left | If the answering message is continuous throughout the first 4 seconds, the platform will evaluate *session.connection.callee\_type* as “answeringmachine” |
| **Resulting Module**  | *welcome\_call\_flow*                                                                                                                                                                                                       | *welcome\_call\_flow*                                                                                                                                                                                                | *leave\_voicemail*                                                                                                                                        |
