{
  "$schema": "https://schema.spbx.tel/v1/structs.realm.lib",
  "flows": {
    "answer": {
      "voicemail_answer": {}
    },
    "sound": {
      "voicemail_greeting": {
        "sound": "sounds/wav_file/voicemail_greeting"
      }
    },
    "record_call": {
      "voicemail_message": {
        "file": "voicemail/%voicemail_mailbox%/%recording_id%.wav",
        "direction": "incoming"
      }
    },
    "set_hangup_task": {
      "voicemail_on_end": {
        "dial_plan": [
          "flows/sub_flow/voicemail_finish"
        ]
      }
    },
    "wait": {
      "voicemail_max_message": {
        "milliseconds": 120000
      }
    },
    "stop_recording": {
      "voicemail_stop": {}
    },
    "set_message_waiting": {
      "voicemail_mwi": {
        "extension": "%voicemail_mailbox%",
        "new_messages": "1",
        "old_messages": "0"
      }
    },
    "send_email": {
      "voicemail_email": {
        "to": "%voicemail_email_to%",
        "subject": "New voicemail for %voicemail_mailbox% from %caller%",
        "body": "Mailbox %voicemail_mailbox% received a new voicemail from %caller%. The message is attached as a WAV file (realm storage path: %recording_file%).",
        "attachment": "%recording_file%"
      }
    },
    "hangup": {
      "voicemail_done": {
        "reason": "voicemail: message recorded"
      }
    },
    "sub_flow": {
      "voicemail_take_message": {
        "dial_plan": [
          "flows/answer/voicemail_answer",
          "flows/sound/voicemail_greeting",
          "flows/record_call/voicemail_message",
          "flows/set_hangup_task/voicemail_on_end",
          "flows/wait/voicemail_max_message",
          "flows/hangup/voicemail_done"
        ]
      },
      "voicemail_finish": {
        "dial_plan": [
          "flows/stop_recording/voicemail_stop",
          "flows/set_message_waiting/voicemail_mwi",
          "flows/sub_flow/voicemail_notify"
        ]
      },
      "voicemail_notify": {
        "dial_plan": [
          "!flows/send_email/voicemail_email"
        ]
      }
    }
  },
  "sounds": {
    "wav_file": {
      "voicemail_greeting": {
        "file_name": "voicemail_greeting.wav"
      }
    }
  }
}
