Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dialtone api Gordon Guthrie Twilio. Twiml - XMHell Hello World.

Similar presentations


Presentation on theme: "Dialtone api Gordon Guthrie Twilio. Twiml - XMHell Hello World."— Presentation transcript:

1 Dialtone api Gordon Guthrie Twilio

2 Twiml - XMHell Hello World

3 bits and bobs Primary Verbs Nouns Secondary Verbs

4 …event cycle… browser app server I wanna do something here’s a capability I am, I can http TwiML Twilio

5 there are some pains

6 …shonktastic… Hello World "AccountSid=yabollocks&ToZip=&FromState=&Called=%2B44131510 1875&FromCountry=GB&CallerCountry=GB&CalledZip=&Direction=i nbound&FromCity=&CalledCountry=GB&CallerState=&CallSid=yaho or&CalledState=Edinburgh&From=%2B447776251669&CallerZip=&Fr omZip=&CallStatus=ringing&ToCity=&ToState=Edinburgh&To=%2B4 41315101875&ToCountry=GB&CallerCity=&ApiVersion=2010-04- 01&Caller=%2B447776251669&CalledCity="

7 …interaction is a pain… dial the website press 1 for X 2 for Y 2 ra punter yer hooter

8 lets make it better

9 turn ‘em both into Erlang Records -record(twilio, { account_sid = [], application_sid = [], direction = [], call_status = [], call_sid = [], api_version = [], custom_params = [], called = null, caller = null, from = null, to = null, call_duration = null, inprogress = null, recording = null }). -record(twilio_caller, { number = [], city = [], zip = [], state = [], country = [], country_code = [], prefix = [] }).

10 -record(say, { voice :: string(), language :: string(), loop :: integer(), text = "" :: string() }).

11 …design goals… make Twiml a proper executable run-time language –with validation implement a run-time make it super-simple to use –don’t debug live systems –don’t create unusable IVR trees

12 …a state machine in URLs… browser app server http TwiML Twilio

13 extended Twiml #say{} #play{} #gather{} #record{} #sms{} #dial{body = [#nouns{}]} Twilio

14 extended Twiml #gather{body = [#ext{}], autoMenuEXT = true, after_EXT = [TwiML]} Nouns #response_EXT{} #default_EXT{} #function_EXT{} #goto_EXT{} #repeat_EXT{} Erlang Flow Of Control

15 …put it all together… SAY = #say{text = "burb"}, PLAY = #play{url = "some file"}, REPEAT = #repeat_EXT{}, RESPONSE = #response_EXT{title = "berk", response = "1", body = [SAY, PLAY]}, GATHER = #gather{autoMenu_EXT = true, body = [SAY, PLAY], after_EXT = [RESPONSE, REPEAT]}, twiml:compile([GATHER], ascii),

16 …compiles to… 1 - GATHER (request Keypad Input) 1.1 - SAY "burb" 1.2 - PLAY some file 1.3 - SAY "Press 1 for BERK. " 1.2 - end of Gather (wait for response) 1.3 - Response 1 : BERK 1.3.1 - SAY "burb" 1.3.2 - PLAY some file 1.3.3 - HANGUP 1.4 - GOTO 1

17 …or… [{"1",{{xml," "},into}}, {"1.1",{{xml," burb "},next}}, {"1.2",{{xml," some file "},next}}, {"1.3",{{xml," Press 1 for BERK. "},next}}, {"1.2",{{xml," "},gather}}, {"1.3",{{response_EXT,"1","berk",[]},into}}, {"1.3.1",{{xml," burb "},next}}, {"1.3.2",{{xml," some file "},next}}, {"1.3.3",{{xml," "},exit}}, {"1.4",{{goto_EXT,"1"},"1"}}]

18 Thanks to Ryan Huffman who wrote the initial implementation https://github.com/huffman/twilio_erlang http://www.twilio.com/docs/libraries


Download ppt "Dialtone api Gordon Guthrie Twilio. Twiml - XMHell Hello World."

Similar presentations


Ads by Google