# Version 2.1.5 Telnyx AMD Voicemail Detection

This patch enables Telnyx Answering Machine Detection on forwarded/transferred calls.

## Goal

Treat voicemail as a missed call.

## What changed

- Adds `answering_machine_detection` to the Telnyx transfer command.
- Defaults to `premium` AMD.
- Adds client state to both call legs so AMD webhooks can find the original caller.
- Handles:
  - `call.machine.detection.ended`
  - `call.machine.premium.detection.ended`
  - `call.machine.greeting.ended`
  - `call.machine.premium.greeting.ended`
- If AMD result is `machine`, `silence`, `fax_detected`, `beep_detected`, `screening`, or `prompt_ended`, app triggers missed-call SMS.
- If AMD result is human/human_residence/human_business, no SMS is sent.

## Environment variables

TELNYX_AMD_ENABLED=true
TELNYX_AMD_MODE=premium
TELNYX_AMD_TIMEOUT_MILLIS=10000
TELNYX_AMD_GREETING_DURATION_MILLIS=2000
VOICEMAIL_TREAT_AS_MISSED=true
BUSINESS_RING_TIMEOUT_SECONDS=25

## Important

For AMD to detect voicemail, the forward ring timeout must be long enough for voicemail to answer.

If voicemail picks up after 20 seconds, set:
BUSINESS_RING_TIMEOUT_SECONDS=25

If the timeout is set too low, Telnyx will timeout before voicemail answers; that can still send SMS, but it will be "no answer" rather than "voicemail detected."
