who wants to be a developer?

136
Cisco Confidential © 2015 Cisco and/or its affiliates. All rights reserved. 1 Who wants to be a Developer? Phil Bellanti Technical Marketing Engineer 2016 May 18th

Upload: cisco-canada

Post on 11-Jan-2017

140 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Who wants to be a Developer?

Cisco Confidential© 2015 Cisco and/or its affiliates. All rights reserved. 1

Who wants to be a Developer?

Phil Bellanti

Technical Marketing Engineer

2016 May 18th

Page 2: Who wants to be a Developer?
Page 3: Who wants to be a Developer?

+• Ask

• Call

• Conference

• Hangup

• Record

• Reject

• Say

• Transfer

Page 4: Who wants to be a Developer?

Inbound Capabilities: User Calls or Texts App

• Surveys / Voting

• Voice Search

• Seasonal Spikes

• Audio Conferencing

• Information Lookup

• Basic Auto Attendant

Page 5: Who wants to be a Developer?

Outbound Capabilities: App Calls or Texts User

• Voice Broadcast

• Conditional Alerts

• Click-to-Call

• Appointment Reminders

• Two Factor Authentication

• Confirmation SMS

Page 6: Who wants to be a Developer?

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

Page 7: Who wants to be a Developer?

<?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 8: Who wants to be a Developer?
Page 9: Who wants to be a Developer?

Incoming Calls

answer();

say("Welcome to Tropo!");

hangup();

Page 10: Who wants to be a Developer?

Incoming Calls

say("Welcome to Tropo!");

Page 11: Who wants to be a Developer?

Try It!

Page 12: Who wants to be a Developer?

Creating your

first application

Page 13: Who wants to be a Developer?

Create an account

• Register at www.Tropo.com

• Create a new application

Page 14: Who wants to be a Developer?
Page 15: Who wants to be a Developer?
Page 16: Who wants to be a Developer?
Page 17: Who wants to be a Developer?

say("hello world");

Page 18: Who wants to be a Developer?
Page 19: Who wants to be a Developer?
Page 20: Who wants to be a Developer?
Page 21: Who wants to be a Developer?
Page 22: Who wants to be a Developer?

Call It!

Page 23: Who wants to be a Developer?
Page 24: Who wants to be a Developer?

Playing Audio

say("http://www.phono.com/audio/trop

orocks.mp3")

Page 25: Who wants to be a Developer?

Playing Audio

say("http://www.phono.com/audio/trop

orocks.mp3

http://www.phono.com/audio/holdmusi

c.mp3")

Page 26: Who wants to be a Developer?

Try It• Create an application that…

• answers an incoming call

• says “Hello Tropo!”

• then plays an audio file.

• If you have a softphone like Jabber, you

can also call in using the application SIP

address

Page 27: Who wants to be a Developer?

Solution

say("Hello Tropo!

http://www.phono.com/audio/troporocks.mp3");

Page 28: Who wants to be a Developer?

Asking Questions

var 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 29: Who wants to be a Developer?

Asking Questions

var result=ask("Pick a number from 0 to 9", {

choices:"0,1,2,3,4,5,6,7,8,9"

});

say("You said " + result.value);

log("They said " + result.value);

Page 30: Who wants to be a Developer?

Grammar Builtins

result=ask("Pick a number from 0 to 9", {

choices:"[1 DIGIT]"

});

say("You said " + result.value);

log("They said " + result.value);

choices:"[4 DIGITS]"

OR

choices:"[4-16 DIGITS]"

Page 31: Who wants to be a Developer?

var result = ask("Which color cup is the Holy Grail?", {

choices: "red, blue, green",

attempts: 3,

onChoice: function(event) {

say("You chose... wisely");

},

onBadChoice: function(event) {

say("You chose... poorly");

}

});

Page 32: Who wants to be a Developer?

Two Styles

result=ask("Pick a number from 0 to 9", {

choices:"[1 DIGIT]"

});

say("You said " + result.value);

var result = ask("Which color cup is the Holy Grail?", {

choices: "red, blue, green",

onChoice: function(event) {

say("You chose... wisely");

},

});

Page 33: Who wants to be a Developer?

ExerciseHow can we add a conditional statement to this

script to repeat back a correct choice?

var result = ask("Which color cup is the Holy Grail?", {

choices: "red, blue, green",

attempts: 3,

onChoice: function(event) {

say("You chose... wisely");

},

onBadChoice: function(event) {

say("You chose... poorly");

}

});

Page 34: Who wants to be a Developer?

Solution

var result = ask("Which color cup is the Holy Grail?", {

choices: "red, blue, green",

attempts: 3,

onChoice: function(event) {

say("You chose... wisely");

},

onBadChoice: function(event) {

say("You chose... poorly");

}

});

if (result.name == "choice") {

say("You chose " + result.value);

}

Page 35: Who wants to be a Developer?

Try It

• Ask the caller to pick a 3-6 digit number

and speak it back to them.

Page 36: Who wants to be a Developer?

Solution

var result=ask("Pick a number 3 to 6 digits long", {

choices:"[3-6 DIGITS]"

});

say("You said " + result.value);

Page 37: Who wants to be a Developer?

Recording

Page 38: Who wants to be a Developer?

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 39: Who wants to be a Developer?

var rec = record("Leave a message.");

say(rec.value);

Page 40: Who wants to be a Developer?

var rec = record("Leave a message.");

say(rec.value);

Page 41: Who wants to be a Developer?

var rec = record("Leave a message.");

say(rec.value);

Page 42: Who wants to be a Developer?

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

ask("What's your favorite color? Choose from red, blue or

green.", {

choices:"red, blue, green"

});

stopCallRecording();

Page 43: Who wants to be a Developer?

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

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

stopCallRecording();

Page 44: Who wants to be a Developer?

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 45: Who wants to be a Developer?

Try It• Voicemail application

• Ask for a message

• Play a beep

• Allow the caller to end recording with #

• Only allow 10 seconds

• Play the message to them when done.

Page 46: Who wants to be a Developer?

Solution

var rec = record("Leave a message.", {

beep:true,

silenceTimeout:3,

maxTime:10,

terminator:'#' }

);

say(rec.value);

Page 47: Who wants to be a Developer?

Outgoing Calls

Page 48: Who wants to be a Developer?
Page 49: Who wants to be a Developer?

Outgoing Calls

call("+14155550100");

say("Tag, you’re it!");

Page 50: Who wants to be a Developer?

Outgoing Calls

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

say("Tag, you’re it!");

Page 51: Who wants to be a Developer?

Outgoing Calls

call("+14155550100");

call("14155550100");

call("4155550100");

call("+1 415 555-0100");

Page 52: Who wants to be a Developer?

Outgoing Calls

call(

[

"+14075550100",

"sip:[email protected]"

]

);

say("Tag, you're it!");

Page 53: Who wants to be a Developer?

call('+' + numberToDial);

say("Hey, "+ customerName +": "+ msg);

POST /rest/1/Sessions

{

"token": "abcdef123456",

"customerName": "John Dyer",

"numberToDial": "14075551212",

"msg": "the sky is falling."

}

Page 54: Who wants to be a Developer?

call('+' + numberToDial);

say("Hey, "+ customerName +": "+ msg);

POST /rest/1/Sessions

{

"token": "abcdef123456",

"customerName": "John Dyer",

"numberToDial": "14075551212",

"msg": "the sky is falling."

}

Page 55: Who wants to be a Developer?

call('+' + numberToDial);

say("Hey, "+ customerName +": "+ msg);

POST /rest/1/Sessions

{

"token": "abcdef123456",

"customerName": "John Dyer",

"numberToDial": "14075551212",

"msg": "the sky is falling."

}

Page 56: Who wants to be a Developer?

call('+' + numberToDial);

POST /rest/1/Sessions

{

"whatever": "14075551212"

}

Page 57: Who wants to be a Developer?

call('+' + numberToDial);

POST /rest/1/Sessions

{

"whatever": "14075551212"

}

Page 58: Who wants to be a Developer?

call('+' + numberToDial);

POST /rest/1/Sessions

{

"whatever": "14075551212"

}

Page 59: Who wants to be a Developer?

call('+' + whatever);

POST /rest/1/Sessions

{

"whatever": "14075551212"

}

Page 60: Who wants to be a Developer?

https://api.tropo.com/1.0/sessions?action=create&tok

en=TOKEN&numberToDial=14074551212

REST Api Shortcut -

URL in browser

Page 61: Who wants to be a Developer?

Try It

• Place a call to your SIP account and say

something.

• Start it with the Session API

• Pass the SIP address in the session Api

Page 62: Who wants to be a Developer?

Solution

call(to);

say("Hello, Tropo!");

POST /rest/1/Sessions

{

"token": "abcdef123456",

"to": "sip:[email protected]",

}

Page 63: Who wants to be a Developer?

Call Failure

Page 64: Who wants to be a Developer?

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 65: Who wants to be a Developer?

Transfers

& Call Control

Page 66: Who wants to be a Developer?

Controlling a Call

transfer("+14075550100");

transfer([

"+14075550100",

"+16505559876"

]);

Page 67: Who wants to be a Developer?

transfer(["+14075550100","sip:[email protected]

4.86"], {

playvalue: "http://example.com/holdmusic.mp3",

terminator: "*",

onTimeout: function(event) {

say("nobody answered");

}

});

Page 68: Who wants to be a Developer?

Try It

• Work with a partner

• Call your Tropo SIP address

• Transfer the call to your partner’s SIP

address.

• Add a ring tone or a terminator

Page 69: Who wants to be a Developer?

Solution

transfer("sip:[email protected]", {

playvalue: "http://example.com/holdmusic.mp3",

terminator: "*",

});

Page 70: Who wants to be a Developer?

Rejecting calls

reject();

var callerID = currentCall.callerID;

if (callerID == "4155550100") {

reject();

}

Page 71: Who wants to be a Developer?

Redirect

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

Page 72: Who wants to be a Developer?

Hanging up

• Explicitly, through hangup();

• When a script ends

• When execution fails

Page 73: Who wants to be a Developer?

Try It

• Reject, redirect, or hang up on a call

Page 74: Who wants to be a Developer?

Conferencing

Page 75: Who wants to be a Developer?

Conferencing

conference("1138");

conference("2600hz");

Page 76: Who wants to be a Developer?

conference("Four score and seven", {

terminator: "*",

playTones: true,

onChoice: function(event) {

say("Disconnecting");

}

});

Page 77: Who wants to be a Developer?

result=ask("What is your conference ID?",

{choices:"[4 DIGITS]"}

);

conference(result.value);

Page 78: Who wants to be a Developer?

conference("12345", {

joinPrompt: "Someone joined",

leavePrompt: "Someone left",

});

Page 79: Who wants to be a Developer?

Try It

• Work with a partner

• Ask for a conference ID

• Ask for the caller’s name (hint: record)

• Play their name into the conference

when they join

Page 80: Who wants to be a Developer?

Solutionvar result=ask("What is your conference ID?",

{choices:"[4 DIGITS]"}

);

var rec = record("Say your name.");

conference(result.value, {

joinPrompt: rec.value + " joined",

leavePrompt: rec.value + " left",

});

Page 81: Who wants to be a Developer?

Text Messaging

Page 82: Who wants to be a Developer?

Text Messages

call("+14155550100",

{network:"SMS"}

);

say("Tag, you’re it!");

Page 83: Who wants to be a Developer?

Text Messages

call("+14155550100",

{network:"SMS"}

);

say("Tag, you’re it!");

Page 84: Who wants to be a Developer?

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

say(msg);

POST /rest/1/Sessions

{

"token": "abcd12345",

"to": "14075551212",

"msg": "the sky is falling."

}

Page 85: Who wants to be a Developer?

Incoming SMS

say("Welcome to Tropo!");

Page 86: Who wants to be a Developer?

Incoming SMS

answer();

say("Welcome to Tropo!");

hangup();

Page 87: Who wants to be a Developer?

Capture an incoming

text message

currentCall.initialText

Page 88: Who wants to be a Developer?

Try It

• Create an inbound SMS app

• Send it a text message and have it reply

back with a response tailored to the

inbound text's content

Page 89: Who wants to be a Developer?

Solution

if(currentCall.initialText == "Yes")

{

say("Awesome, I totally agree.");

}

else if(currentCall.initialText == "No")

{

say("Well that's just too bad");

}

else

{

say("That wasn't an option, sorry");

}

Page 90: Who wants to be a Developer?

Multichannel

say("Thanks for your call. We'll text you the

information.");

hangup();

call(currentCall.callerID, {

network:"SMS"});

say("Here's what you asked for.");

Page 91: Who wants to be a Developer?

Multichannel

say("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 92: Who wants to be a Developer?

Message Shortcut

message("Here's what you asked for.",

{

to: "+16505551212",

network: "SMS"}

);

Page 93: Who wants to be a Developer?

Message Shortcut

say("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 94: Who wants to be a Developer?

Call Data

Page 95: Who wants to be a Developer?

Call Properties

• calledID

• calledName

• callerID

• callerName

• channel

• network

• id

• sessionId

• isActive function

Page 96: Who wants to be a Developer?

Reading Caller ID

if (currentCall.callerID == "4075550100") {

say("Sending you to Adam.");

transfer("+19166002497");

}

Page 97: Who wants to be a Developer?

Setting Caller ID

call("+19165550101", {

callerID:"+14075550100"

});

transfer("+19165550100", {

callerID: "14075550100"

});

Page 98: Who wants to be a Developer?

Try It

• Call your SIP address

• Read your caller ID back to yourself

Page 99: Who wants to be a Developer?

Solution

say("You are calling from " + currentCall.callerID);

Page 100: Who wants to be a Developer?

Advanced Speech

Concepts

Page 101: Who wants to be a Developer?

Speech Control

say("1234");

“One thousand two hundred thirty four”

Page 102: Who wants to be a Developer?

Speech Control

say("1 2 3 4");

“One Two Three Four”

Page 103: Who wants to be a Developer?

SSML

say("<speak>

<say-as interpret-as='vxml:digits'>

1234

</say-as>

</speak>");

“One Two Three Four”

Page 104: Who wants to be a Developer?

say-as

• currency

• number

• phone

• date

• time

interpret-as='vxml:digits'

Page 105: Who wants to be a Developer?

Prosody

say("<speak>One potato, two potato, three potato,

four. <prosody rate='-50%'>One potato, two

potato, three potato, four.</prosody></speak>");

Page 106: Who wants to be a Developer?

TTS Fallback

say('<speak>

<audio src="http://example.com/welcome.wav">

This text will be spoken if

the audio file can not be

played.

</audio>

</speak>');

Page 107: Who wants to be a Developer?

Try It

• Speak “1234” as “one thousand two

hundred thirty four” and then as digits

Page 108: Who wants to be a Developer?

Solution

say("1234");

say("1 2 3 4");

say("<speak>

<say-as interpret-as = 'vxml:digits'>

1234

</say-as>

</speak>");

Page 109: Who wants to be a Developer?

Grammars

• SimpleGrammar

• hamburger(burger, cheeseburger, hamburger)

• GrXML

• ABNF

• SRGS

Page 110: Who wants to be a Developer?

SimpleGrammar

var foo = ask("Who?", {

choices: "department(support, engineering,

sales), person(jose, jason, adam)",

});

say("You said " + foo.choice.interpretation + ",

which is a " +

foo.value);

Page 111: Who wants to be a Developer?

External Grammars

var result = ask("What's your destination?", {

choices:"http://example.com/tropo/destinations.grxml

"

});

Page 112: Who wants to be a Developer?

<?xml version="1.0"?>

<grammar xmlns="http://www.w3.org/2001/06/grammar" root="main">

<rule id="main" scope="public">

<item repeat="1-16">

<ruleref uri="#digit">

<tag>out.concept = out.concept + rules.digit;</tag>

</ruleref>

</item>

</rule>

<rule id="digit">

<one-of>

<item>0</item>

<item>1</item>

<item>2</item>

<item>3</item>

<item>4</item>

<item>5</item>

<item>6</item>

<item>7</item>

<item>8</item>

<item>9</item>

</one-of>

</rule>

</grammar>

Page 113: Who wants to be a Developer?

Audio Playback

• 8kHz, 8bit u-law (wav or raw) (*.wav or *.ulaw)

• 8kHz, 8bit a-law (wav or raw) (*.wav or *.alaw)

• 8kHz, 8bit pcm (wav) (*.wav)

• 8khz, 16bit pcm (wav or raw) (*.wav or *.pcm)

• MS-GSM (wav) (*.wav)

• GSM 6.10 (raw) (*.gsm)

• MP3

Page 114: Who wants to be a Developer?

Method Details

Page 115: Who wants to be a Developer?

Ask

• Collect input

Text

allowSignals

bargein

attempts

choices

interdigitTimeout

minConfidence

mode

onBadChoice

onChoice

onError

Page 116: Who wants to be a Developer?

Ask Result

attempt – This will return an integer which will relay

what attempt the user is currently on.

value – This will return the users selection.

name – This will return the event that was accepted:

choice, badChoice, timeout, error

timestamp – This will return the timestamp of the

completed ask 2013-09-09T18:59:06.267Z

Page 117: Who wants to be a Developer?

Call

destination

machineDetection

allowSignals

network

answerOnMedia

onAnswer

callerID

onBusy

channel

onCallFailure

• Outgoing Calls & Messages

headers

onError

onSignal

onTimeout

recordFormat

recordMethod

recordURI

timeout

voice

Page 118: Who wants to be a Developer?

Call Result

value – a call object representing the state of the

current call.

timestamp – this will return the timestamp of the of the

connected call 2013-09-09T18:59:06.267Z

Page 119: Who wants to be a Developer?

Conference

• Joins two or more calls in a conference.

Limited only by server capacity.

conferenceId

allowSignals

interdigitTimeout

joinPrompt

onHangup

onSignal

playTones

terminator

leavePrompt

mute

onChoice

onError

Page 120: Who wants to be a Developer?

Hangup

• Disconnect a call or end a SIP session

• Automatic at the end of the script

Page 121: Who wants to be a Developer?

Log

• Insert a line into the application logs

• Note: in PHP, this is _log()

• Only parameter is the string to insert into

the log

log("The user name is " + name);

Page 122: Who wants to be a Developer?

Message

• Message-sending shortcut

• Equivalent to call, say, hangup sequence

to

callerID

channel

network

timeout

Page 123: Who wants to be a Developer?

Record• Record user input

• See also startCallRecording &

stopCallRecordingonEvent

allowSignals

onHangup

attempts

onRecord

bargein

onSignal

beep

onTimeout

interdigitTimeout

recordFormat

maxTime

recordMethod

onError

recordPassword

recordUser

silenceTimeout

terminator

timeout

transcriptionID

transcriptionOutFormat

transcriptionOutURI

voice

Page 124: Who wants to be a Developer?

Reject

• Return a busy signal instead of

answering

• CDR has a duration of 0

Page 125: Who wants to be a Developer?

Say

• Speak TTS or play audio URL (or both)

• Does not await a response

text

allowSignals

onError

onHangup

onSignal

voice

Page 126: Who wants to be a Developer?

startCallRecording

• Non-blocking, turns on a recording

• Local leg in one audio channel, remote leg in

another

• Stop with stopCallRecording

url

format

method

recordPassword

recordUser

transcriptionEmailFormat

transcriptionID

transcriptionOutURI

Page 127: Who wants to be a Developer?

stopCallRecording

• Takes no parameters

• Stops the active call recording and

triggers upload

Page 128: Who wants to be a Developer?

Transfer

• Simple mechanism to call a new number

and bridge to the current call

destination

allowSignals

answerOnMedia

callerID

headers

interdigitTimeout

onBusy

onCallFailure

onConnect

onError

onSignal

onSuccess

onTimeout

playrepeat

playValue

terminator

timeout

voice

Page 129: Who wants to be a Developer?

wait

• Pauses specified number of milliseconds

• Differs from built-in sleep function by

being interruptible

• In Groovy use await()

milliseconds

onSignal

allowSignals

Page 130: Who wants to be a Developer?

Rest APIs

Page 131: Who wants to be a Developer?

Session

• Start a new session

• Send a signal to an existing session

Page 132: Who wants to be a Developer?

Conference

• Mute and unmute participants

• Play an audio file to all members of a

conference

Page 133: Who wants to be a Developer?

Provisioning

• Manage applications, users, and phone

numbers

• Full role-based access control

• Tropo Commander and UI both built on

this

Page 134: Who wants to be a Developer?

WebAPI

Page 135: Who wants to be a Developer?

What is it?

• Uses JSON over http to communicate

with Tropo

• Most large-scale customers stick with

Scripting

• Web Scale issues

Page 136: Who wants to be a Developer?

Thank you.