Overview

It is a voice menu. You ask a question, list the possible answers, and then wait for input (DTMF) from the caller/called.
For example: Welcome to the company, for sales please press one, for support please press two.

Method Calls

Method Returns Description
x.ask(text:String); Play an announcement. the text can either be an id of your recorded voice file or a text which will be converted to speech (Text-to-Speech = TTS).
x.ask(text:String, params:Object); Play an announcement and then listen for user input. The text can either be an id of your recorded voice file or a text which will be converted to speech (Text-to-Speech = TTS). The paramsobject contains all the extra parameters like callback functions, Text to Speech language, repeat count etc.


Parameters Object

property Mandatory Description
callId No The callId of the call you want to ask your question, and wait for digits to be entered. If you do not provide a callId, then the callId of the most recent call operation will be used.
language No This parameter is used with Text to Speech to determine the language you want to say your text. The default is english that is "en", German is "de", Spanish is "es" and so on.
repeat No How many times shoud the server repeat your announcement (voice file or TTS) The default value is 1.
onHangup No Execute this function when -the call we were listening on- was hang up.
onChoice No Execute this function when a digit was entered.
onPlayFinished No Execute this function when the announcement was played repeat number of times

Examples

play 3 times the voice file with id=4, and then write a log, when the all plays finish.

    x.answer();
    x.ask("4", {
    repeat: 3,
    onPlayFinished: function() {
      x.log("Play finished.");
    }
  });
  
Convert the text to voice and play it 3 times, write a log line, when the user pressed a button on his phone.

    var incomingCallId = x.answer();
    x.ask("Hi There, please press any button", {
    repeat: 3,
    callId: incomingCallId,
    onChoice function(event) {
      x.log("OnChoice: " + event.value);
    }
  });