View
221
Download
0
Category
Preview:
Citation preview
Web developers are everywhereWeb developers are everywhere
HTML
PHP RubyRESTJavascript
JSONHTTP
Python
Java
<?php $options = array('choices' => '1 (1, sales), 2 (2, support)'); $result = ask('Hi. For sales, say Sales or press 1. For support, say Support or press 2.', $options); if ($result->name == 'choice') { switch ($result->value) { case 1: say('Your money is important to us.'); break; case 2: say('Your call will be ignored in the order received.'); break; } } ?>
PHP <?php answer(); say("Hello World"); hangup(); ?>
Javascript answer(); say("Hello World"); hangup();
Ruby answer say "Hello World" hangup
Python answer() say("Hello World") hangup()
Groovy answer() say("Hello World") hangup()
JSON {"tropo":[{ "say": "Hello World" }]}
akalsey@cisco.com
• Call • Answer • Transfer • Reject • Hangup • Redirect • Message
• Say • Ask • Record • Conference • call Recording • Wait • Log • getHeader
akalsey@cisco.com
Developer Web Server
Scripting Environment
PSTN
2. HTTP GET
REST API
1. POST /sessions
3. Outgoing call
akalsey@cisco.com
Playing Audiosay("http://www.phono.com/audio/troporocks.mp3 http://www.phono.com/audio/holdmusic.mp3")
akalsey@cisco.com
Try It!• Replace “hello world” with the URL to an
audio file • What happens if you use both “hello
world AND an audio file?
akalsey@cisco.com
Asking Questionsvar result = ask("What's your favorite color? Choose from red, blue or green.", { choices:"red, blue, green" }); say("You said " + result.value); log("They said " + result.value);
akalsey@cisco.com
Try It!
var result = ask("color?", { choices:"red, green" }); say("You said " + result.value);
akalsey@cisco.com
Languagessay("hola.", { voice:'Juan' } );
ask("color favorito", { choices:'rojo,azul', voice:'Juan', recognizer:'es-us'} );
akalsey@cisco.com
Try It!say("hola.", { voice:'Paulina' } );
ask("color favorito", { choices:'rojo,azul', voice:'Paulina', recognizer:'es-us'} );
akalsey@cisco.com
record("Leave your message at the beep. Press pound when finished.", { beep:true, timeout:10, silenceTimeout:7, maxTime:60, terminator:'#', recordFormat:"audio/mp3", recordURI:"ftp://example.com/1.mp3", recordUser:"tropocloud", recordPassword:"password" } );
akalsey@cisco.com
startCallRecording("http://example.com/recording.js");
ask("What's your favorite color? Choose from red, blue or green.", { choices:"red, blue, green" });
stopCallRecording();
akalsey@cisco.com
startCallRecording("http://example.com/recording.js");
transfer("sip:alice@example.com");
stopCallRecording();
akalsey@cisco.com
var callerID = currentCall.callerID; say("Welcome to speed therapy!"); record("Tell us how you feel in fifteen minutes or less!", { beep:true, maxTime:900, recordURI:"http://example.com/recording.js", transcriptionOutURI:"mailto:you@aol.com", transcriptionID:callerID } );
akalsey@cisco.com
Try It!res = record("Leave your message", { terminator:'#', recordURI:"???", recordUser:"???", recordPassword:"???" } );
say(res.value);
akalsey@cisco.com
Outgoing Callscall("+14155550100");call("14155550100");call("4155550100");call("+1 415 555-0100");
akalsey@cisco.com
Outgoing Callscall( [ "+14075550100", "sip:alice@example.com" ]); say("Tag, you're it!");
akalsey@cisco.com
call('+' + numberToDial); say("Hey, "+ customerName +": "+ msg);
POST /1.0/sessions
{ "token": "abcdef123456", "customerName": "Troposaurus", "numberToDial": "14075551212", "msg": "the sky is falling." }
akalsey@cisco.com
call('+' + numberToDial); say("Hey, "+ customerName +": "+ msg);
POST /1.0/sessions
{ "token": "abcdef123456", "customerName": "Troposaurus", "numberToDial": "14075551212", "msg": "the sky is falling." }
akalsey@cisco.com
call('+' + numberToDial); say("Hey, "+ customerName +": "+ msg);
POST /1.0/sessions
{ "token": "abcdef123456", "customerName": "Troposaurus", "numberToDial": "14075551212", "msg": "the sky is falling." }
akalsey@cisco.com
call('+14155550100', { timeout:120, onAnswer: function() { say("Tag, you are it!"); log("Obnoxious call complete"); }, onTimeout: function() { log("Call timed out"); }, onCallFailure: function() { log("Call could not be completed as dialed"); } });
akalsey@cisco.com
Controlling a Calltransfer("+14075550100");
transfer([ "+14075550100", "+16505559876" ]);
akalsey@cisco.com
transfer(["+14075550100","sip:12345678912@221.122.54.86"], { playvalue: "http://example.com/holdmusic.mp3", terminator: "*", onTimeout: function(event) { say("nobody answered"); } });
akalsey@cisco.com
conference("Four score and seven", { terminator: "*", playTones: true, onChoice: function(event) { say("Disconnecting"); } });
akalsey@cisco.com
result=ask("What is your conference ID?", {choices:"[4 DIGITS]"} ); conference(result.value);
akalsey@cisco.com
conference("12345", { joinPrompt: "Someone joined", leavePrompt: "Someone left", });
akalsey@cisco.com
Try It!
• Call your neighbor’s number and join their conference.
conference("1138");
akalsey@cisco.com
call('+' + to, {network:"SMS"});say(msg);
POST /1.0/sessions
{ "token": "abcd12345", "to": "14075551212", "msg": "the sky is falling." }
akalsey@cisco.com
Multichannelsay("Thanks for your call. We'll text you the information.");
hangup(); call(currentCall.callerID, { network:"SMS"}); say("Here's what you asked for.");
akalsey@cisco.com
Multichannel
say("Thanks for your call. We'll text you the information."); call(currentCall.callerID, { network:"SMS"}); say("Here's what you asked for.");
This “say” will go to the currentCall, not the new call.
akalsey@cisco.com
Multichannelsay("Thanks for your call. We'll text you the information."); hangup(); var newcall = call(currentCall.callerID, { network:"SMS"}); newcall.value.say("Here's what you asked for.");
akalsey@cisco.com
Message Shortcut
message("Here's what you asked for.", { to: "+16505551212", network: "SMS"} );
akalsey@cisco.com
Message Shortcutsay("Thanks for your call. We'll text you the information."); message("Here's what you asked for.", { to: currentCall.callerID, network: "SMS"} ); say("This goes to the voice call.");
akalsey@cisco.com
Call Properties• calledID • calledName • callerID • callerName • channel • network
akalsey@cisco.com
Reading Caller IDif (currentCall.callerID == "4075550100") { say("Sending you to Adam."); transfer("+19166002497"); }
akalsey@cisco.com
Setting Caller IDcall("+19165550101", { callerID:"+14075550100" });
transfer("+19165550100", { callerID: "14075550100" });
akalsey@cisco.com
Sending a SIP Headervar account = ask("Enter your account ID", { choices:"[4-5 DIGITS]" } );transfer("sip:agent@example.com", { headers: { "x-account-id":account.value } });
akalsey@cisco.com
SSMLsay("<speak> <say-as interpret-as='digits'> 1234 </say-as> </speak>");
“One Two Three Four”
akalsey@cisco.com
Prosodysay("<speak>One potato, two potato, three potato, four. <prosody rate='-50%'>One potato, two potato, three potato, four.</prosody></speak>");
akalsey@cisco.com
TTS Fallbacksay('<speak> <audio src="http://example.com/welcome.wav"> This text will be spoken if the audio file can not be played. </audio></speak>');
Recommended