{
  "description": "Elevator help line: instructions, problem report, transfer to on-call operator",
  "initial_state": "Trigger",
  "flags": {
    "allow_concurrent_calls": true
  },
  "states": [
    {
      "name": "Trigger",
      "type": "trigger",
      "transitions": [
        {
          "event": "incomingMessage"
        },
        {
          "event": "incomingCall",
          "next": "welcome_menu"
        },
        {
          "event": "incomingConversationMessage"
        },
        {
          "event": "incomingRequest"
        },
        {
          "event": "incomingParent"
        }
      ],
      "properties": {
        "offset": {
          "x": 283,
          "y": 0
        }
      }
    },
    {
      "name": "welcome_menu",
      "type": "gather-input-on-call",
      "transitions": [
        {
          "event": "keypress",
          "next": "split_menu"
        },
        {
          "event": "speech",
          "next": "split_menu"
        },
        {
          "event": "timeout",
          "next": "say_transfer"
        }
      ],
      "properties": {
        "voice": "Polly.Joanna-Generative",
        "language": "en-US",
        "say": "Hello, this is the elevator help line. For elevator instructions, press 1. To report a problem, press 2. To speak with the on-call operator, press 3. If you're trapped, stay calm. You don't need to press anything. We'll connect you to someone right away.",
        "loop": 1,
        "timeout": 5,
        "number_of_digits": 1,
        "stop_gather": true,
        "offset": {
          "x": 322,
          "y": 140
        }
      }
    },
    {
      "name": "split_menu",
      "type": "split-based-on",
      "transitions": [
        {
          "event": "noMatch",
          "next": "say_transfer"
        },
        {
          "event": "match",
          "next": "say_manual",
          "conditions": [
            {
              "friendly_name": "1 - User manual",
              "arguments": [
                "{{widgets.welcome_menu.Digits}}"
              ],
              "type": "equal_to",
              "value": "1"
            }
          ]
        },
        {
          "event": "match",
          "next": "say_report",
          "conditions": [
            {
              "friendly_name": "2 - Report a fault",
              "arguments": [
                "{{widgets.welcome_menu.Digits}}"
              ],
              "type": "equal_to",
              "value": "2"
            }
          ]
        },
        {
          "event": "match",
          "next": "say_transfer",
          "conditions": [
            {
              "friendly_name": "3 - Human agent",
              "arguments": [
                "{{widgets.welcome_menu.Digits}}"
              ],
              "type": "equal_to",
              "value": "3"
            }
          ]
        }
      ],
      "properties": {
        "input": "{{widgets.welcome_menu.Digits}}",
        "offset": {
          "x": 242,
          "y": 336
        }
      }
    },
    {
      "name": "say_manual",
      "type": "say-play",
      "transitions": [
        {
          "event": "audioComplete",
          "next": "welcome_menu"
        }
      ],
      "properties": {
        "voice": "Polly.Joanna-Generative",
        "language": "en-US",
        "say": "This elevator runs daily from 7 a.m. to 11 p.m. and carries up to 1,000 kilograms. If the power goes out, the emergency light turns on automatically. If you're ever stuck, don't try to force the doors open. Stay inside and wait for help. Returning to the main menu.",
        "loop": 1,
        "offset": {
          "x": 0,
          "y": 512
        }
      }
    },
    {
      "name": "say_report",
      "type": "say-play",
      "transitions": [
        {
          "event": "audioComplete",
          "next": "record_fault"
        }
      ],
      "properties": {
        "voice": "Polly.Joanna-Generative",
        "language": "en-US",
        "say": "After the beep, tell us what happened and which floor you're on. Press pound when you're done.",
        "loop": 1,
        "offset": {
          "x": 342,
          "y": 512
        }
      }
    },
    {
      "name": "record_fault",
      "type": "record-voicemail",
      "transitions": [
        {
          "event": "recordingComplete",
          "next": "say_thanks"
        },
        {
          "event": "noAudio",
          "next": "say_transfer"
        },
        {
          "event": "hangup"
        }
      ],
      "properties": {
        "max_length": 120,
        "timeout": 5,
        "finish_on_key": "#",
        "play_beep": "true",
        "trim": "trim-silence",
        "offset": {
          "x": 342,
          "y": 708
        }
      }
    },
    {
      "name": "say_thanks",
      "type": "say-play",
      "transitions": [
        {
          "event": "audioComplete"
        }
      ],
      "properties": {
        "voice": "Polly.Joanna-Generative",
        "language": "en-US",
        "say": "Thanks. We've received your report, and a technician will follow up soon. Goodbye.",
        "loop": 1,
        "offset": {
          "x": 326,
          "y": 884
        }
      }
    },
    {
      "name": "say_transfer",
      "type": "say-play",
      "transitions": [
        {
          "event": "audioComplete",
          "next": "connect_agent"
        }
      ],
      "properties": {
        "voice": "Polly.Joanna-Generative",
        "language": "en-US",
        "say": "Connecting you to the on-call operator. Please hold.",
        "loop": 1,
        "offset": {
          "x": 668,
          "y": 894
        }
      }
    },
    {
      "name": "connect_agent",
      "type": "connect-call-to",
      "transitions": [
        {
          "event": "callCompleted"
        },
        {
          "event": "hangup"
        }
      ],
      "properties": {
        "noun": "number",
        "to": "+14155551212",
        "caller_id": "+14155550100",
        "timeout": 30,
        "record": false,
        "offset": {
          "x": 668,
          "y": 1080
        }
      }
    }
  ]
}
