developing tropo applications

75
Tropo Development

Upload: cisco-devnet

Post on 11-Apr-2017

220 views

Category:

Technology


0 download

TRANSCRIPT

Tropo Development

Adam Kalsey Manager, Technical [email protected]@akalsey

www.Tropo.com @Tropo

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" }]}

[email protected]

• Call • Answer • Transfer • Reject • Hangup • Redirect • Message

• Say • Ask • Record • Conference • call Recording • Wait • Log • getHeader

[email protected]

Developer Web Server

Scripting Environment

PSTN

HTTP GET Incoming call

[email protected]

Developer Web Server

Scripting Environment

PSTN

2. HTTP GET

REST API

1. POST /sessions

3. Outgoing call

Creating your first application

[email protected]

Create an account• Register at www.Tropo.com

[email protected]

Incoming Callssay("Welcome to Tropo!");

[email protected]

Incoming Callsanswer();say("Welcome to Tropo!");hangup();

[email protected]

Try It!

[email protected]

say("hello world");

[email protected]

Call It!

[email protected]

Playing Audiosay("http://www.phono.com/audio/troporocks.mp3")

[email protected]

Playing Audiosay("http://www.phono.com/audio/troporocks.mp3 http://www.phono.com/audio/holdmusic.mp3")

[email protected]

Try It!• Replace “hello world” with the URL to an

audio file • What happens if you use both “hello

world AND an audio file?

[email protected]

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);

[email protected]

Try It!

var result = ask("color?", { choices:"red, green" }); say("You said " + result.value);

[email protected]

Languagessay("hola.", { voice:'Juan' } );

ask("color favorito", { choices:'rojo,azul', voice:'Juan', recognizer:'es-us'} );

[email protected]

Try It!say("hola.", { voice:'Paulina' } );

ask("color favorito", { choices:'rojo,azul', voice:'Paulina', recognizer:'es-us'} );

[email protected]

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" } );

[email protected]

startCallRecording("http://example.com/recording.js");

ask("What's your favorite color? Choose from red, blue or green.", { choices:"red, blue, green" });

stopCallRecording();

[email protected]

startCallRecording("http://example.com/recording.js");

transfer("sip:[email protected]");

stopCallRecording();

[email protected]

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:[email protected]", transcriptionID:callerID } );

[email protected]

Try It!res = record("Leave your message", { terminator:'#', recordURI:"???", recordUser:"???", recordPassword:"???" } );

say(res.value);

[email protected]

Outgoing Callscall("+14155550100"); say("Tag, you’re it!");

[email protected]

Outgoing Callscall("sip:[email protected]"); say("Tag, you’re it!");

[email protected]

Outgoing Callscall("+14155550100");call("14155550100");call("4155550100");call("+1 415 555-0100");

[email protected]

Outgoing Callscall( [ "+14075550100", "sip:[email protected]" ]); say("Tag, you're it!");

[email protected]

call('+' + numberToDial); say("Hey, "+ customerName +": "+ msg);

POST /1.0/sessions

{ "token": "abcdef123456", "customerName": "Troposaurus", "numberToDial": "14075551212", "msg": "the sky is falling." }

[email protected]

call('+' + numberToDial); say("Hey, "+ customerName +": "+ msg);

POST /1.0/sessions

{ "token": "abcdef123456", "customerName": "Troposaurus", "numberToDial": "14075551212", "msg": "the sky is falling." }

[email protected]

call('+' + numberToDial); say("Hey, "+ customerName +": "+ msg);

POST /1.0/sessions

{ "token": "abcdef123456", "customerName": "Troposaurus", "numberToDial": "14075551212", "msg": "the sky is falling." }

[email protected]

call('+' + numberToDial);

POST /1.0/sessions

{ "whatever": "14075551212" }

[email protected]

call('+' + numberToDial);

POST /1.0/sessions

{ "whatever": "14075551212" }

[email protected]

call('+' + numberToDial);

POST /1.0/sessions

{ "whatever": "14075551212" }

[email protected]

call('+' + whatever);

POST /1.0/sessions

{ "whatever": "14075551212" }

[email protected]

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"); } });

[email protected]

Controlling a Calltransfer("+14075550100");

transfer([ "+14075550100", "+16505559876" ]);

[email protected]

transfer(["+14075550100","sip:[email protected]"], { playvalue: "http://example.com/holdmusic.mp3", terminator: "*", onTimeout: function(event) { say("nobody answered"); } });

[email protected]

Conferencing

conference("1138");

conference("2600hz");

[email protected]

conference("Four score and seven", { terminator: "*", playTones: true, onChoice: function(event) { say("Disconnecting"); } });

[email protected]

result=ask("What is your conference ID?", {choices:"[4 DIGITS]"} ); conference(result.value);

[email protected]

conference("12345", { joinPrompt: "Someone joined", leavePrompt: "Someone left", });

[email protected]

Try It!

• Call your neighbor’s number and join their conference.

conference("1138");

[email protected]

Text Messagescall("+14155550100", {network:"SMS"}); say("Tag, you’re it!");

[email protected]

Text Messagescall("+14155550100", {network:"SMS"}); say("Tag, you’re it!");

[email protected]

call('+' + to, {network:"SMS"});say(msg);

POST /1.0/sessions

{ "token": "abcd12345", "to": "14075551212", "msg": "the sky is falling." }

[email protected]

Incoming SMSsay("Welcome to Tropo!");

[email protected]

Multichannelsay("Thanks for your call. We'll text you the information.");

hangup(); call(currentCall.callerID, { network:"SMS"}); say("Here's what you asked for.");

[email protected]

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.

[email protected]

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.");

[email protected]

Message Shortcut

message("Here's what you asked for.", { to: "+16505551212", network: "SMS"} );

[email protected]

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.");

[email protected]

Call Properties• calledID • calledName • callerID • callerName • channel • network

[email protected]

Reading Caller IDif (currentCall.callerID == "4075550100") { say("Sending you to Adam."); transfer("+19166002497"); }

[email protected]

Setting Caller IDcall("+19165550101", { callerID:"+14075550100" });

transfer("+19165550100", { callerID: "14075550100" });

[email protected]

SIP HeaderscurrentCall.getHeader(“x-account-num");

[email protected]

Sending a SIP Headervar account = ask("Enter your account ID", { choices:"[4-5 DIGITS]" } );transfer("sip:[email protected]", { headers: { "x-account-id":account.value } });

[email protected]

Speech Controlsay("1234");

“One thousand two hundred thirty four”

[email protected]

Speech Controlsay("1 2 3 4");

“One Two Three Four”

[email protected]

SSMLsay("<speak> <say-as interpret-as='digits'> 1234 </say-as> </speak>");

“One Two Three Four”

[email protected]

say-as

• currency • number • phone

interpret-as='digits'

[email protected]

Prosodysay("<speak>One potato, two potato, three potato, four. <prosody rate='-50%'>One potato, two potato, three potato, four.</prosody></speak>");

[email protected]

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>');

Adam Kalsey Manager, Technical [email protected]@akalsey

www.Tropo.com @Tropo