VoiceTel

Support / VoiceML examples / Build extension dialing and a line test with VoiceML

Build extension dialing and a line test with VoiceML.

A fictional defense computer answers the phone. Pressing 1 calls another company’s switchboard and keys an extension automatically once it answers, so the caller never navigates someone else’s menu. Pressing 2 starts a line test that plays the caller’s own voice back to them. It is one document published on voiceml.org, with no application server.

Free trial <Number> reference

What callers get

  • An extension, dialed for them

    sendDigits waits for the other system to answer, pauses, and keys the extension, so callers reach a person behind someone else’s menu with one key.

  • A line test

    <Echo> plays everything the caller says back to them, to check for delay, echo, or poor audio on their line.

  • A touch tone as a cue

    <Play digits> plays a touch tone to mark the start of the test, with no audio file needed.

Before you start

  1. A VoiceML account with a phone number. See VoiceML or start a free trial.
  2. The number of the phone system to dial into, the extension, and how long its greeting runs before it accepts keys.

The switchboard number and extension in this document are fictional. The number uses the 555-0100 to 555-0199 range, which is set aside for fiction. Replace both before you publish.

Step 1: Publish the document and point the number at it

Replace the switchboard number and the extension in sendDigits, then publish it at voiceml.org and set the /r/ URL it returns as the phone number’s voice URL. Keep the URL exactly as returned, key included, and don’t post it publicly.

main.xml

<Response>
  {% if Digits == blank %}
    <Gather input="dtmf" numDigits="1" timeout="5" method="POST">
      <Pause length="1"/>
      <Say>Greetings, Professor Falken. Shall we play a game?</Say>
      <Pause length="1"/>
      <Say>To be connected to Dr. Falken's extension, press 1. For a line test, press 2.</Say>
    </Gather>
    <Say>A strange game. The only winning move is not to play. Goodbye.</Say>
    <Hangup/>

  <!-- Press 1: call the switchboard, wait two seconds after it answers, then key the extension -->
  {% elsif Digits == "1" %}
    <Say>Connecting you to Dr. Falken. We will dial his extension for you.</Say>
    <Dial timeout="30" ringTone="us">
      <Number sendDigits="wwww1983#">+15415550100</Number>
    </Dial>
    <Say>Goodbye.</Say>
    <Hangup/>

  <!-- Press 2: everything the caller says is played back until they hang up -->
  {% elsif Digits == "2" %}
    <Say>Line test. After the tone, everything you say will be played back to you, so you can hear how your line sounds. Hang up when you are finished.</Say>
    <Play digits="#"/>
    <Echo/>

  {% else %}
    <Gather input="dtmf" numDigits="1" timeout="5" method="POST">
      <Say>How about a nice game of chess? Or press 1 for Dr. Falken, or 2 for a line test.</Say>
    </Gather>
    <Say>A strange game. The only winning move is not to play. Goodbye.</Say>
    <Hangup/>
  {% endif %}
</Response>

Step 2: Test it

  1. Call the number and press 2. After the tone, speak; you hear yourself a moment later. Hang up to end the test.
  2. Call again and press 1. Listen as the switchboard answers and the extension is keyed for you.

How it works

The markup behind each feature
Markup What it does
<Number sendDigits="wwww1983#">After the dialed number answers, waits two seconds (each w is half a second, each W a full second), then sends the keys 1, 9, 8, 3, and # on that call.
<Play digits="#"/>Plays the # touch tone to the caller, a beep with no audio file to host.
<Echo/>Plays the caller’s own audio back to them until they hang up. Nothing after it runs, so it comes last.

Tune the pause in sendDigits to the system you call: if the keys arrive while its greeting is still playing, it may ignore them. Add a w for every half second more it needs.

Where the movie turns up

References to WarGames in the call flow
Where Reference
The greeting“Greetings, Professor Falken. Shall we play a game?”, the WOPR computer’s words.
Option 1Dr. Stephen Falken, who lives on an island off the coast of Oregon, area code 541; his extension is the film’s release year.
A wrong key“How about a nice game of chess?”
No key at all“A strange game. The only winning move is not to play.”

Limits of this design

  • The keys are sent blind. sendDigits follows its timing, not what the other system says. If that system changes its greeting or menu, update the pauses and keys.
  • The line test runs until the caller hangs up. <Echo> has no time limit and no way to continue to another verb.
  • One fixed extension. To let callers choose, give each key its own <Number sendDigits>.

Credits

  • The WOPR, Dr. Falken, and their lines come from WarGames (1983), directed by John Badham and distributed by MGM/UA. Matthew Broderick plays David Lightman, the high school hacker who finds the WOPR while war dialing for a game company; Ally Sheedy plays Jennifer Mack; and John Wood plays Dr. Stephen Falken and voices the WOPR.
  • The switchboard, its extension, and its phone number are fictional in this example. VoiceTel is not affiliated with the film or its rights holders.
  • References: the <Number> reference, the <Echo> reference, and the <Play> reference.

Trusted by