Javascript Example - Collect Account Number
About
Basic prompt and collect DTMF application.
Code
function sayphrase(phrase, args)
{
console_log("sayphrase: phrase=[" + phrase + "] args=[" + args + "]\n");
var rtn = session.execute("phrase", phrase + "," + args);
return(rtn);
}
var dtmf;
if (session.ready()) {
session.answer();
session.execute("sleep","1000");
sayphrase("enteraccount", ""); /* enter your 8 digit account number */
dtmf = session.getDigits(8, "", 10000); /* Get 8 digits waiting 10 seconds*/
sayphrase("saydigits",dtmf); /* you entered XXXXXXXX */
session.hangup();
}
Macro
Phrases used in this example.
<macro name="enteraccount">
<input pattern="(.*)">
<match>
<action function="execute" data="sleep(500)"/>
<action function="speak-text" data="Enter your account number"/>
</match>
</input>
</macro>
<macro name="saydigits">
<input pattern="(.*)">
<match>
<action function="execute" data="sleep(500)"/>
<action function="speak-text" data="You entered $1"/>
</match>
</input>
</macro>