{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://jambonz.org/schema/callbacks/amd",
  "title": "AMD ActionHook Payload",
  "description": "Payload sent to the AMD actionHook when an answering machine detection event occurs. Multiple events may fire during a single call (e.g. amd_machine_detected followed by amd_machine_stopped_speaking or amd_tone_detected).",
  "allOf": [{ "$ref": "base" }],
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "description": "The AMD event type. IMPORTANT: This field is 'type', NOT 'amd_type'.",
      "enum": [
        "amd_human_detected",
        "amd_machine_detected",
        "amd_no_speech_detected",
        "amd_decision_timeout",
        "amd_machine_stopped_speaking",
        "amd_tone_detected",
        "amd_tone_timeout",
        "amd_error",
        "amd_stopped"
      ]
    },
    "reason": {
      "type": "string",
      "description": "Reason for the detection result (e.g. 'short greeting', 'long greeting', 'hint', 'digit count'). Present on amd_human_detected and amd_machine_detected events."
    },
    "greeting": {
      "type": "string",
      "description": "The transcribed greeting text. Present on amd_human_detected and amd_machine_detected events."
    },
    "hint": {
      "type": "string",
      "description": "The voicemail hint that matched, if detection was triggered by hint matching."
    },
    "language": {
      "type": "string",
      "description": "Language code from the transcription (e.g. 'en-US'). Present on amd_human_detected and amd_machine_detected events."
    },
    "frequency": {
      "type": "number",
      "description": "Frequency of the detected beep in Hz. Present on amd_tone_detected events."
    },
    "variance": {
      "type": "number",
      "description": "Frequency variance of the detected beep. Present on amd_tone_detected events."
    }
  },
  "required": ["type"]
}
