Top Banner
Tropo Development
75

Developing Tropo Applications

Apr 11, 2017

Download

Technology

Cisco DevNet
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Developing Tropo Applications

Tropo Development

Page 2: Developing Tropo Applications

Adam Kalsey Manager, Technical [email protected]@akalsey

www.Tropo.com @Tropo

Page 3: Developing Tropo Applications

Web developers are everywhereWeb developers are everywhere

HTML

PHP RubyRESTJavascript

JSONHTTP

Python

Java

Page 4: Developing Tropo Applications

<?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; } } ?>

Page 5: Developing Tropo Applications

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

Page 6: Developing Tropo Applications

[email protected]

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

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

Page 7: Developing Tropo Applications

[email protected]

Developer Web Server

Scripting Environment

PSTN

HTTP GET Incoming call

Page 8: Developing Tropo Applications

[email protected]

Developer Web Server

Scripting Environment

PSTN

2. HTTP GET

REST API

1. POST /sessions

3. Outgoing call

Page 9: Developing Tropo Applications

Creating your first application

Page 10: Developing Tropo Applications

[email protected]

Create an account• Register at www.Tropo.com

Page 11: Developing Tropo Applications

[email protected]

Incoming Callssay("Welcome to Tropo!");

Page 12: Developing Tropo Applications

[email protected]

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

Page 13: Developing Tropo Applications

[email protected]

Try It!

Page 17: Developing Tropo Applications

[email protected]

say("hello world");

Page 22: Developing Tropo Applications

[email protected]

Call It!

Page 24: Developing Tropo Applications

[email protected]

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

Page 25: Developing Tropo Applications

[email protected]

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

Page 26: Developing Tropo Applications

[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?

Page 27: Developing Tropo Applications

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

Page 28: Developing Tropo Applications

[email protected]

Try It!

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

Page 29: Developing Tropo Applications

[email protected]

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

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

Page 30: Developing Tropo Applications

[email protected]

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

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

Page 31: Developing Tropo Applications

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

Page 32: Developing Tropo Applications

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

Page 33: Developing Tropo Applications

[email protected]

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

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

stopCallRecording();

Page 34: Developing Tropo Applications

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

Page 35: Developing Tropo Applications

[email protected]

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

say(res.value);

Page 36: Developing Tropo Applications

[email protected]

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

Page 37: Developing Tropo Applications

[email protected]

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

Page 38: Developing Tropo Applications

[email protected]

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

Page 39: Developing Tropo Applications

[email protected]

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

Page 40: Developing Tropo Applications

[email protected]

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

POST /1.0/sessions

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

Page 41: Developing Tropo Applications

[email protected]

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

POST /1.0/sessions

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

Page 42: Developing Tropo Applications

[email protected]

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

POST /1.0/sessions

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

Page 43: Developing Tropo Applications

[email protected]

call('+' + numberToDial);

POST /1.0/sessions

{ "whatever": "14075551212" }

Page 44: Developing Tropo Applications

[email protected]

call('+' + numberToDial);

POST /1.0/sessions

{ "whatever": "14075551212" }

Page 45: Developing Tropo Applications

[email protected]

call('+' + numberToDial);

POST /1.0/sessions

{ "whatever": "14075551212" }

Page 46: Developing Tropo Applications

[email protected]

call('+' + whatever);

POST /1.0/sessions

{ "whatever": "14075551212" }

Page 47: Developing Tropo Applications

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

Page 48: Developing Tropo Applications

[email protected]

Controlling a Calltransfer("+14075550100");

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

Page 49: Developing Tropo Applications

[email protected]

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

Page 50: Developing Tropo Applications

[email protected]

Conferencing

conference("1138");

conference("2600hz");

Page 51: Developing Tropo Applications

[email protected]

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

Page 52: Developing Tropo Applications

[email protected]

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

Page 53: Developing Tropo Applications

[email protected]

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

Page 54: Developing Tropo Applications

[email protected]

Try It!

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

conference("1138");

Page 55: Developing Tropo Applications

[email protected]

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

Page 56: Developing Tropo Applications

[email protected]

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

Page 57: Developing Tropo Applications

[email protected]

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

POST /1.0/sessions

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

Page 58: Developing Tropo Applications

[email protected]

Incoming SMSsay("Welcome to Tropo!");

Page 59: Developing Tropo Applications

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

Page 60: Developing Tropo Applications

[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.

Page 61: Developing Tropo Applications

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

Page 62: Developing Tropo Applications

[email protected]

Message Shortcut

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

Page 63: Developing Tropo Applications

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

Page 64: Developing Tropo Applications

[email protected]

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

Page 65: Developing Tropo Applications

[email protected]

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

Page 66: Developing Tropo Applications

[email protected]

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

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

Page 67: Developing Tropo Applications

[email protected]

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

Page 68: Developing Tropo Applications

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

Page 69: Developing Tropo Applications

[email protected]

Speech Controlsay("1234");

“One thousand two hundred thirty four”

Page 70: Developing Tropo Applications

[email protected]

Speech Controlsay("1 2 3 4");

“One Two Three Four”

Page 71: Developing Tropo Applications

[email protected]

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

“One Two Three Four”

Page 72: Developing Tropo Applications

[email protected]

say-as

• currency • number • phone

interpret-as='digits'

Page 73: Developing Tropo Applications

[email protected]

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

Page 74: Developing Tropo Applications

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

Page 75: Developing Tropo Applications

Adam Kalsey Manager, Technical [email protected]@akalsey

www.Tropo.com @Tropo