VoiceTel

Support / VoiceML examples / Build a multilingual line with VoiceML

Build a multilingual line with VoiceML.

Rick’s Café Américain is a fictional nightclub with an international crowd. Its line announces each language option in that language, then greets the caller, gives the opening hours, and connects them to the bar in the language they chose. It is one document published on voiceml.org, with no application server.

Free trial Text-to-speech guide

What callers get

  • Options in their own language

    “For English, press 1. Pour le français, appuyez sur 2. Für Deutsch, drücken Sie 3. Para español, pulse 4.”, each in a native voice.

  • The rest of the call in that language

    The greeting, the opening hours, and the goodbye are all spoken in the language the caller chose.

  • Keypad, not speech

    Callers choose with a key, so no speech recognition is needed in any language.

Before you start

  1. A VoiceML account with a phone number. See VoiceML or start a free trial.
  2. Text-to-speech for your languages. The built-in voices speak English, Spanish, French, and German, with nothing to set up. For other languages, add your own text-to-speech provider; see the text-to-speech guide.

The bar’s number in this document is fictional. It uses the 555-0100 to 555-0199 range, which is set aside for fiction. Replace it with a real number before you publish.

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

Replace the bar’s number and the opening hours with your own, 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 %}
    <!-- Each option is announced in its own language -->
    <Gather input="dtmf" numDigits="1" timeout="5" method="POST">
      <Pause length="1"/>
      <Say language="en-US">Welcome to Rick's Café Américain. For English, press 1.</Say>
      <Say language="fr-FR">Pour le français, appuyez sur 2.</Say>
      <Say language="de-DE">Für Deutsch, drücken Sie 3.</Say>
      <Say language="es-ES">Para español, pulse 4.</Say>
    </Gather>
    <Say language="en-US">We did not receive a selection. Goodbye.</Say>
    <Hangup/>

  {% elsif Digits == "1" %}
    <Say language="en-US">We are open every night from 8 p.m. to 2 a.m. Of all the gin joints in all the towns in all the world, you called ours. Connecting you to the bar.</Say>
    <Dial timeout="25" ringTone="us">
      <Number>+12125550142</Number>
    </Dial>
    <Say language="en-US">Here's looking at you, kid. Goodbye.</Say>
    <Hangup/>

  {% elsif Digits == "2" %}
    <Say language="fr-FR">Bienvenue au Rick's Café Américain. Nous sommes ouverts tous les soirs de 20 heures à 2 heures du matin. Nous vous mettons en relation avec le bar.</Say>
    <Dial timeout="25" ringTone="us">
      <Number>+12125550142</Number>
    </Dial>
    <Say language="fr-FR">Merci de votre appel. Au revoir.</Say>
    <Hangup/>

  {% elsif Digits == "3" %}
    <Say language="de-DE">Willkommen in Rick's Café Américain. Wir haben jeden Abend von 20 Uhr bis 2 Uhr nachts geöffnet. Wir verbinden Sie jetzt mit der Bar.</Say>
    <Dial timeout="25" ringTone="us">
      <Number>+12125550142</Number>
    </Dial>
    <Say language="de-DE">Vielen Dank für Ihren Anruf. Auf Wiederhören.</Say>
    <Hangup/>

  {% elsif Digits == "4" %}
    <Say language="es-ES">Bienvenido al Rick's Café Américain. Abrimos todas las noches de las ocho de la tarde a las dos de la madrugada. Le pasamos con el bar.</Say>
    <Dial timeout="25" ringTone="us">
      <Number>+12125550142</Number>
    </Dial>
    <Say language="es-ES">Gracias por su llamada. Adiós.</Say>
    <Hangup/>

  {% else %}
    <Gather input="dtmf" numDigits="1" timeout="5" method="POST">
      <Say language="en-US">For English, press 1.</Say>
      <Say language="fr-FR">Pour le français, appuyez sur 2.</Say>
      <Say language="de-DE">Für Deutsch, drücken Sie 3.</Say>
      <Say language="es-ES">Para español, pulse 4.</Say>
    </Gather>
    <Say language="en-US">We did not receive a selection. Goodbye.</Say>
    <Hangup/>
  {% endif %}
</Response>

Step 2: Test it

Call the number and listen: each option is read in its own language. Press 2, and the rest of the call is in French; call again and press 3 for German.

How the languages work

Every <Say> has a language attribute. With the built-in voices, only the first part of the code matters:

Languages in this document
Key language Built-in voice
1en-USEnglish
2fr-FRFrench
3de-DEGerman
4es-ESSpanish; es-MX sounds the same with the built-in voices

With the built-in voices, any other language is read in English, so a language beyond these four needs a text-to-speech provider that speaks it.

The whole call happens in one document on purpose. Values can’t carry from one voiceml.org document to the next, so a second document wouldn’t know which language the caller picked. Each language’s branch says everything that language needs.

Where the movie turns up

References to Casablanca in the call flow
Where Reference
The greetingRick’s Café Américain, whose customers include French and German officials and refugees hoping to reach America.
The English branch“Of all the gin joints in all the towns in all the world,” adapted to “you called ours.”
The English goodbye“Here’s looking at you, kid.”

Limits of this design

  • Speech input is English by default. This line uses the keypad. To let callers speak their choice in another language, add a speech recognizer that supports it and set language on the <Gather>.
  • The menu always starts in English. The first sentence is English for everyone. To start in another language, change the order or the first <Say>.
  • One bar for every language. Each branch rings the same number. To send each language to its own staff, give each branch its own <Number>.

Credits

  • Rick’s Café Américain and its lines come from Casablanca (1942), directed by Michael Curtiz and distributed by Warner Bros. Humphrey Bogart plays Rick Blaine, Ingrid Bergman plays Ilsa Lund, Claude Rains plays Captain Louis Renault, and Dooley Wilson plays Sam.
  • The café’s hours and phone number are fictional in this example. VoiceTel is not affiliated with the film or its rights holders.
  • References: the text-to-speech guide, the <Say> reference, and the voiceml.org publishing and integration guide.

Trusted by