Getting Started: Developing Tropo Applications

Post on 08-Jan-2017

66 views 0 download

Transcript of Getting Started: Developing Tropo Applications

Getting Started Developing Tropo Applications

Phil Bellanti - Technical Marketing EngineerDEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1023 2

• Introductions• Tropo Overview

• Incoming Calls• Outgoing Calls• Advanced Features

• Text Messaging (SMS)• Advanced Speech Concepts• REST APIs• What is WebAPI?• Questions?

Agenda

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 3

Cloud APIs enabling developers to quickly

and easily embed communication capabilities into their applications and business processes.

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 4

Old-styleCommunicationDevelopment

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 5

+• Ask • Call • Conference • Hangup

• Record • Reject • Say • Transfer

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 6

PHP<?phpanswer();say("Hello World");hangup();?>

Javascriptanswer();say("Hello World");hangup();

Rubyanswersay "Hello World"hangup

Pythonanswer()say("Hello World")hangup()

Groovyanswer()say("Hello World")hangup()

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 7

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Incoming Calls

9DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 10DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 11

Inbound Capabilities: User Calls or Texts App

• Surveys / Voting

• Voice Search

• Seasonal Spikes

• Audio Conferencing

• Information Lookup

• Basic Auto Attendant

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 12

Incoming Calls

answer();say("Welcome to Tropo!");hangup();

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 13

Incoming Callssay("Welcome to Tropo!");

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 14

Playing Audio

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 15

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 16

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 17

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Outgoing Calls

18DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 19DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 20

Outbound Capabilities: App Calls or Texts User

• Voice Broadcast

• Conditional Alerts

• Click-to-Call

• Appointment Reminders

• Two Factor Authentication

• Confirmation SMS

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 21

Outgoing Calls

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 22

Outgoing Calls

call("sip:alice@example.com");say("Tag, you’re it!");

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 23

Outgoing Calls

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 24

Outgoing Calls

call( [ "+14075550100", "sip:alice@example.com" ]);say("Tag, you're it!");

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

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

POST /rest/1/Sessions{ "token": "abcdef123456", "customerName": "John Dyer", "numberToDial": "14075551212", "msg": "the sky is falling."}

25DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

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

POST /rest/1/Sessions{ "token": "abcdef123456", "customerName": "John Dyer", "numberToDial": "14075551212", "msg": "the sky is falling."}

26DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

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

POST /rest/1/Sessions{ "token": "abcdef123456", "customerName": "John Dyer", "numberToDial": "14075551212", "msg": "the sky is falling."}

27DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

call('+' + numberToDial);

POST /rest/1/Sessions{ "whatever": "14075551212"}

28DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

call('+' + numberToDial);

POST /rest/1/Sessions{ "whatever": "14075551212"}

29DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

call('+' + numberToDial);

POST /rest/1/Sessions{ "whatever": "14075551212"}

30DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

call('+' + whatever);

POST /rest/1/Sessions{ "whatever": "14075551212"}

31DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Transfers & Call Control

32DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 33

Controlling a Call

transfer("+14075550100");

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

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

34DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 35

Rejecting calls

reject();

var callerID = currentCall.callerID;if (callerID == "4155550100") { reject();}

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 36

Redirect

redirect("sip:alice@example.com");

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Recording

37DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

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

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

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

39DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

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

40DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

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

41DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

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

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

stopCallRecording();

42DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Caller ID

43DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 44

Reading Caller ID

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 45

Setting Caller ID

call("+19165550101", { callerID:"+14075550100"});

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 46

Rejecting calls

reject();

var callerID = currentCall.callerID;if (callerID == "4155550100") { reject();}

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Hanging up• Explicitly, through hangup();• When a script ends• When execution fails

47DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Conferencing

48DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 49

Conferencing

conference("1138");

conference("2600hz");

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

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

50DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

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

51DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Text Messaging

52DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 53

Text Messages

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 54

Text Messages

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

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

POST /rest/1/Sessions{ "token": "abcd12345", "to": "14075551212", "msg": "the sky is falling."}

55DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 56

Incoming SMS

say("Welcome to Tropo!");

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 57

First SMS Message

currentCall.initialText;

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 58

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 59

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Advanced Speech Concepts

60DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 61

Speech Control

say("1234");

“One thousand two hundred thirty four”

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 62

Speech Control

say("1 2 3 4");

“One Two Three Four”

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 63

SSML

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

“One Two Three Four”

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 64

say-as

• currency• number• phone• date• time

interpret-as='vxml:digits'

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 65

Prosody

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 66

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 67

Grammars• SimpleGrammar

• hamburger(burger, cheeseburger, hamburger)

• GrXML• ABNF• SRGS

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 68

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

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 69

External Grammars

var result = ask("What's your destination?", { choices:"http://example.com/tropo/destinations.grxml"});

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

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

70DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

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

71DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Rest APIs

72DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Session• Start a new session• Send a signal to an existing session

73DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Conference• Mute and unmute participants• Play an audio file to all members of a conference

74DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Provisioning• Manage applications, users, and phone numbers• Full role-based access control• Tropo Commander and UI both built on this

75DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 76

WebAPI

DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

What is it?• Uses JSON over http to communicate with Tropo• Most large-scale customers stick with Scripting• Web Scale issues

77DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Complete Your Online Session Evaluation

Don’t forget: Cisco Live sessions will be available for viewing on-demand after the event at CiscoLive.com/Online

• Give us your feedback to be entered into a Daily Survey Drawing. A daily winner will receive a $750 Amazon gift card.

• Complete your session surveys through the Cisco Live mobile app or from the Session Catalog on CiscoLive.com/us.

78DEVNET-1023

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 79DEVNET-1023

Continue Your Education• Tropo.com ScriptingAPI Quickstart Guide:

https://www.tropo.com/docs/scripting/quickstarts

• More Learning Labs Available:https://developer.cisco.com/site/devnet/overview/index.gsp

• Follow @Tropo and @PBellanti on Twitter

• Stay Up to Date on All Things Tropo:https://www.tropo.com/category/blog/

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public

Please join us for the Service Provider Innovation Talk featuring:

Yvette Kanouff | Senior Vice President and General Manager, SP BusinessJoe Cozzolino | Senior Vice President, Cisco Services

Thursday, July 14th, 201611:30 am - 12:30 pm, In the Oceanside A room

What to expect from this innovation talk• Insights on market trends and forecasts• Preview of key technologies and capabilities • Innovative demonstrations of the latest and greatest products• Better understanding of how Cisco can help you succeed

Register to attend the session live now or watch the broadcast on cisco.com

DEVNET-1023 80

Thank you

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 81DEVNET-1023