We've prepared for you several IVR examples covering standard IVR trees.

Important: The links to files in play commands are not valid and serve only as examples. Real links are generated automatically once you add and insert your own recordings.

Basic example

online:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=connect-first-available-agent.mp3
  - ring
queue:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=next-in-queue.mp3
offline:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=we-are-currently-not-available-check-website.mp3
  - voicemail

When agents are online, connect-first-available-agent.mp3 is played and the call rings to the first available agent. If all agents are busy, the call is placed in the queue and next-in-queue.mp3 is played as queue music. When nobody is online to take the call, the offline announcement we-are-currently-not-available-check-website.mp3 is played and the caller can leave a voicemail.

Advanced example

start:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=connect-first-available-agent.mp3
  - choice:
      1:
        name: Sales department
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=press-one-for-sales.mp3
        do:
          - transfer:
              to: salesDepartmentID
              if:
                online:
                  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=connect-first-available-agent.mp3
                  - ring
                offline:
                  - goto: voicemail
      2:
        name: Technical department
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=press-two-for-technical-support.mp3
        do:
          - transfer:
              to: techDepID
              if:
                online:
                  - ring
                offline:
                  - goto: offline
      3:
        name: Request calback
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=press_2_to_request_callback.mp3
        do:
          - callback
voicemail:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=leave-a-voicemail.mp3
  - voicemail
offline:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=we-are-currently-not-available-check-website.mp3
queue:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=next-in-queue.mp3
  - choice:
      0:
        name: Wait
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=press-zero-to-wait-in-queue.mp3
        goto: queue
      1:
        name: Leave voicemail
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=press-one-to-leave-a-voicemail.mp3
        goto: voicemail

The IVR starts in the start section by playing the connect-first-available-agent.mp3 welcome message. After that, the choice messages press-one-for-sales.mp3, press-two-for-technical-support.mp3 and press_2_to_request_callback.mp3 are played in a loop. The caller can press a key at any time while the choices are being played.

If the caller presses 1, the call is transferred to the Sales department. Replace salesDepartmentID with the ID of your department. When agents of the Sales department are online, connect-first-available-agent.mp3 is played and the call rings to them. When nobody from the department is online, the call continues in the voicemail section, which plays leave-a-voicemail.mp3 and lets the caller record a voicemail.

If the caller presses 2, the call is transferred to the Technical department. Replace techDepID with the ID of your department. When agents of the Technical department are online, the call rings to them. When nobody from the department is online, the call continues in the offline section, which plays we-are-currently-not-available-check-website.mp3.

If the caller presses 3, the call is hung up and a callback request is placed in the calls queue, where it waits until an available agent picks it up. Read more in Automatic callback request.

If all agents are busy, the caller is placed in the queue section. next-in-queue.mp3 is played and then the caller can press 0 to keep waiting or 1 to leave a voicemail.

Note: The choice command can be written in two ways. In the start section, each option runs a list of commands under do. In the queue section, each option jumps directly to another section with goto. You can use whichever is more convenient for you.

If you need the caller's consent before a call is recorded (for example to comply with GDPR), you can let the caller decide in the IVR whether the call will be recorded. Two IVR commands are available for this:

  • recording_on – the call will be recorded.
  • recording_off – the call will not be recorded.

The commands override the Record incoming calls setting of the phone number for the current call only. They do not take any parameters. The usual way to use them is inside a choice, so that the caller presses a key to allow or refuse the recording:

start:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=welcome-call-recording-consent.mp3
  - choice:
      1:
        name: Allow recording
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=press-one-to-allow-recording.mp3
        do:
          - recording_on
          - goto: connect
      2:
        name: Do not record
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=press-two-to-not-allow-recording.mp3
        do:
          - recording_off
          - goto: connect
connect:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=connect-first-available-agent.mp3
  - ring
offline:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=we-are-currently-not-available-check-website.mp3
  - voicemail
queue:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=next-in-queue.mp3

The IVR starts in the start section by playing the welcome-call-recording-consent.mp3 message, for example: "Thank you for calling. To improve the quality of our service, we would like to record this call." After that, the choice messages press-one-to-allow-recording.mp3 and press-two-to-not-allow-recording.mp3 are played in a loop until the caller presses a key.

If the caller presses 1, call recording is turned on. If the caller presses 2, call recording is turned off. In both cases the call continues in the connect section, which plays connect-first-available-agent.mp3 and rings the call to the first available agent. The call is recorded only if the caller pressed 1.

The caller's choice is shown in the call ticket as a system message "Turning on call recording" or "Turning off call recording", so agents can see whether the caller agreed to the recording.

Note: Place recording_on or recording_off before the step that connects the caller to an agent (ring or transfer). The commands do not start or stop a recording that is already running – they set whether the call will be recorded when it is answered.

Tip: To ask for consent only for a specific department, put recording_on or recording_off right before the transfer command of that department in the do list.

Dynamic IVR example

start:
  - fetch:
      url: https://my.dynamic.script
      onError: offline
      params:
        from: {$from_number}
        to: {$to_number}
        ticket: {$conv_code}
offline:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=leave-a-voicemail.mp3
  - voicemail
queue:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=next-in-queue.mp3

If you want to generate the IVR script dynamically, for example based on who is calling, use the fetch command. In the example above, the start section has only one step. It sends a POST request to https://my.dynamic.script, and the call continues in the start section of the IVR returned by your script.

The parameters listed under params are sent in the request body as standard form data (application/x-www-form-urlencoded), the same way an HTML form is submitted. In this example the body can look like from=421900123456&to=421233000000&ticket=ABC-DEFGH-123. Placeholders such as {$from_number} are replaced with the values of the current call before the request is sent. You can add as many parameters as you need, and only these parameters are sent.

Tip: To see all variables you can use, such as the caller's contact details or ticket fields, click the small ⓘ icon in the lower right corner of the IVR editor. Variables can be used anywhere in the IVR script of the phone number, but they are not replaced in the IVR returned by your script.

The returned IVR can use goto to jump to any section of the main script (in this example start, offline and queue), so you don't have to repeat sections such as offline or queue in your script.

For example, your script recognizes the caller's number and returns the following IVR, which plays a personalized welcome message and then rings the call to agents:

start:
  - play: https://hello.john
  - ring

Your script must respond with HTTP status 200 and return the IVR script in the response body, with correct formatting and indentation. The content type of the response does not matter, so you can use e.g. text/plain or application/yaml.

Note: If the request to your script fails or the script does not return a valid IVR, the call continues in the section set in onError. If onError is not set, the fetch step is skipped.

DTMF input example

start:
  - play: https://enter.your.dtmf.input.and.press.#.to.confirm
  - dtmf:
      url: https://my.dynamic.script
      onError: offline
      params:
        ticket: {$conv_code}
        value: DTMF_VALUE
offline:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=we-are-currently-not-available-check-website.mp3
queue:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=next-in-queue.mp3

If you want the caller to enter some input, for example an order number, use the dtmf command. In the example above, a message asks the caller to enter the input and confirm it with the # key. The dtmf command then collects the pressed keys until the caller presses #.

The input is then sent to your script in the same way as in the Dynamic IVR example. The DTMF_VALUE placeholder in params is replaced with the entered digits, and your script returns the IVR which the call continues with. If the request fails or the returned IVR is not valid, the call continues in the section set in onError.

Note: The dtmf command waits until the caller presses #, so always tell the caller to confirm the input with the # key.

Waiting in queue without pressing a key example

If you don't want the caller to press a key to keep waiting in the queue, and only want to offer pressing 1 to leave a voicemail, write the queue section like this:

queue:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=next_in_queue.mp3
  - choice:
      0:
        name: Hidden option with music file
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=queue_music.mp3
        goto: queue
      1:
        name: Leave voicemail
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=press_one_to_leave_a_voicemail.mp3
        goto: voicemail

When the caller is placed in the queue, next_in_queue.mp3 is played and then the choices loop: queue_music.mp3, press_one_to_leave_a_voicemail.mp3, queue_music.mp3 again and so on. Option 0 is hidden, because the caller is never asked to press 0 and it only plays the queue music. The caller stays in the queue until they press 1 to leave a voicemail or until an agent is available to take the call.

Note: The voicemail section must be defined in your IVR, as in the Advanced example.

Multi-language IVR example

If you want to offer the IVR in multiple languages, e.g. English and German, it can look like this example:

start:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=connect-first-available-agent.mp3
  - choice:
      1:
        name: English
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=press-one-for-english-langauge.mp3
        goto: english
      2:
        name: German
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=press-two-for-german-language.mp3
        goto: german
english:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=connect-first-available-agent.mp3
  - choice:
      1:
        name: Sales department
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=press-one-for-sales.mp3
        do:
          - transfer:
              to: SalesDepartmentID
              if:
                online:
                  - ring
                offline:
                  - goto: voicemail
      2:
        name: Technical department
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=press-two-for-technical-support.mp3
        do:
          - transfer:
              to: TechnicalDepartmentID
              if:
                online:
                  - ring
                offline:
                  - goto: offline
german:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=connect-first-available-agent.mp3
  - choice:
      1:
        name: German Sales department
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=press-one-for-sales.mp3
        do:
          - transfer:
              to: germanSalesDepartmentID
              if:
                online:
                  - ring
                offline:
                  - goto: germanvoicemail
                queue:
                  - goto: germanqueue
      2:
        name: German Technical department
        play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=press-two-for-technical-support.mp3
        do:
          - transfer:
              to: germanTechnicalDepartmentID
              if:
                online:
                  - ring
                offline:
                  - goto: germanoffline
                queue:
                  - goto: germanqueue
voicemail:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=leave-a-voicemail.mp3
  - voicemail
offline:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=we-are-currently-not-available-check-website.mp3
queue:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=next-in-queue.mp3
germanvoicemail:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=leave-a-voicemail-german-language.mp3
  - voicemail
germanoffline:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=we-are-currently-not-available-check-website-german-language.mp3
germanqueue:
  - play: https://mycompany.ladesk.com/scripts/file.php?view=Y&file=next-in-queue-german-language.mp3

The start section plays the welcome message and lets the caller choose a language. Pressing 1 continues in the english section and pressing 2 in the german section. Each language section offers its own choice of departments and transfers the call to the department for that language. When nobody is online, the call continues in the voicemail or offline section of the selected language. German callers who wait in the queue continue in the germanqueue section, which plays next-in-queue-german-language.mp3.

×