Evented Telephony Application Design with Adhearsion


Summarized using AI

Evented Telephony Application Design with Adhearsion

Ben Klang • September 29, 2011 • New Orleans, Louisiana • Talk

The video titled "Evented Telephony Application Design with Adhearsion" features speaker Ben Klang at RubyConf 2011. This talk introduces Adhearsion, a framework that revolutionizes voice application development by providing features similar to web development frameworks like Ruby on Rails. Adhearsion focuses on code reuse and offers a test-driven development approach that simplifies the creation of complex telephony applications.

Key Points:

  • Overview of Adhearsion:

    • Adhearsion is aimed at making voice applications easier to develop by linking the voice layer with various APIs and systems, enhancing flexibility and performance.
    • It operates on Ruby, allowing developers familiar with the language to create applications that can run on multiple platforms including Asterisk and Tropo.
  • Use Cases for Adhearsion:

    • Call center workflows where contextual information is vital, integrating with CRMs and other back-office applications to improve customer service.
    • Applications for sales automation and interactive voice response (IVR), which are streamlined and not frustrating for users.
    • Novel applications such as interactive public art projects and gaming via telephony, showcasing the versatility of the framework.
  • Integration with Telephony Platforms:

    • Adhearsion supports integration with multiple telephony platforms, primarily Asterisk, while also facilitating cloud-based solutions with Tropo. The framework is designed to handle high concurrency and is cloud-ready, addressing enterprise needs.
  • Evented Design in Telephony:

    • Explores the concept of evented programming, where applications react to events such as DTMF key presses or call state changes, rather than following a linear execution path. This enhances interactivity and responsiveness within voice applications.
    • The framework uses a domain-specific language (DSL) that simplifies handling events in a user-friendly manner, enabling developers to implement features without complicated code.
  • Future Developments and Community Support:

    • The talk highlighted upcoming enhancements in Adhearsion 2.0 aimed at unifying event handling across different platforms and paving the way for potential support for additional systems like FreeSWITCH.
    • Community resources, documentation, and ongoing support through events and blogs are emphasized to assist developers in adopting Adhearsion effectively.

Conclusion

Ben Klang’s presentation showcases Adhearsion as an innovative solution for developing voice applications, emphasizing ease of use, scalability, and the ability to quickly integrate with existing systems. The evented design approach is particularly powerful in creating responsive applications that react dynamically to user interactions, making Adhearsion a compelling choice for modern telephony challenges.

Evented Telephony Application Design with Adhearsion
Ben Klang • New Orleans, Louisiana • Talk

Date: September 29, 2011
Published: December 12, 2011
Announced: unknown

Adhearsion is a new way to write voice-enabled applications. It's not just an API or library -- it's a fully-featured framework, the first of its kind, designed for maximal code reuse and intuitiveness. Building on ideas learned from existing Ruby web development frameworks, Adhearsion brings test-driven development, ActiveRecord models and the full power of the Ruby language to the world of telephone applications. This talk covers Adhearsion's powerful eventing interfaces for call control. Rather than handling each call session in a linear (and often blocking) sequence, we can react to events as they happen during the call, such as code reacting to the active speaker in a multi-channel conference, handling mid-call DTMF keypresses or manipulating state as calls are set up and torn down.

RubyConf 2011

00:00:17.000 good afternoon everyone afterno good you're not all asleep it's actually a
00:00:22.400 tough act to follow the whiskey panel so I'm glad there's still people in here um
00:00:27.640 my name is Ben clang I have a in Atlanta called Mojo lingo we build voice applications that work like magic and
00:00:34.440 I'm also the leader of the adhesion project which is why I'm here to talk to you today uh so before I get started how
00:00:39.960 many of you have heard of adhesion very nice okay how many of you have tried it right okay and anyone
00:00:47.320 have't production yeah cool all right so a lot of you have heard of it looked like not
00:00:53.000 all of you have tried it let me just briefly go through what adhesion is so Jay Phillips the author of adher called
00:01:00.519 it adhesion that you can hear it glues The Voice layer to the rest of the world it is a voice application development
00:01:06.360 framework you're all in here are familiar with rails so rails is a a framework for developing web
00:01:11.720 applications adhesion is a framework for developing voice applications provides a lot of that same nice functionality that
00:01:17.680 you need uh things like logging and demonization u a plug-in system really makes lets you focus on building the
00:01:24.439 voice application as opposed to all of the other stuff it is of course open source and runs on Ruby we provide
00:01:31.079 functionality to easily integrate with rails but it is not dependent on Rails it's a totally Standalone project um
00:01:37.360 integrating with rails is obviously a great thing we we can automatically load all of your helpers and your models so
00:01:43.040 you can reuse a lot of code um but you don't have to it's platform agnostic
00:01:48.079 runs anywhere Ruby or J Ruby does um which is really nice any uh especially for Enterprise people who are kind of
00:01:53.439 stuck on the jbm J J Ru is a great Target for it it runs fairly fairly
00:01:58.960 small it's not a a heavyweight framework but it can scale pretty large we've personally seen uh in my experience
00:02:05.320 hundreds of concurrent calls in a single adherent instance and usually what happens is the telep platform is the
00:02:10.640 limiting factor uh we haven't actually run out of adher resources yet and it's cloud ready which um it's kind of a buzz
00:02:16.800 word but I'll talk about what that means in just a minute so usually when I tell people
00:02:21.879 that I build voice applications the first thing they say is that's cool but what do you do with it so this is uh
00:02:28.200 just talk a minute about some of the ways you can actually use this adhesion is uh one of the great ways to do it is
00:02:34.560 call center workflow so almost every business has some need to take calls from their customers this can be you
00:02:40.560 know the two guys at the startup would just need to handle customer service all the way up to a professional call center of 500 seats whatever the thing they
00:02:47.239 have in common is they really need to have contextual information about the people they're talking to and one thing
00:02:52.400 inher can do is tie in things like your CRM whether that's something you have local or something in a cloud it can tie
00:02:58.640 in your your issue tracking system your Finance system if you need to know you know whether an account is current and
00:03:03.959 you can present all this information in real time to the person taking the call U you can do that through a web
00:03:09.159 application you can do that through maybe an instant message uh but the point is that it really brings in these two normally separate disparate systems
00:03:16.560 and brings them to a single unified application pretty cool uh the same would be largely true for things like
00:03:22.400 Salesforce automation keeping track of um you know customer relationship so for
00:03:27.640 example when you're calling out to a customer you want to keep notes of the call you could for example record the
00:03:32.799 call and keep and let the uh sales agent type notes as he goes and then correlate those after the fact so there's really
00:03:38.640 really cool applications mixing different Technologies together in the startup World we're seeing some pretty cool conferencing
00:03:45.400 applications anything from finding a person who needs help and connecting them with an expert who can provide that
00:03:50.799 help or uh chat applications like text messaging that you can then bring
00:03:56.239 everyone who's on that text message Bridge into a voice conference again multimodal the kind of the classic place
00:04:02.799 is ivr interactive voice response if you don't know what ivr is it's that really annoying thing when you call your bank
00:04:08.159 or you call that Airline and sends you to an infinite Loop um well with adher you can do that but but not be
00:04:13.680 annoying and other use cases would be polling so political candidates or robocalling things like calling to
00:04:20.400 remind you that your prescription is available now these are the kind of bread and butter of adher this is what
00:04:25.759 we do kind of day in and day out but it's this isn't all you can do uh one example is we have actually I have has
00:04:33.000 anyone here heard of the AR drone it's made by parrot okay if you haven't heard of it it's a four bladed helicopter and
00:04:40.199 uh it flies it's you know this big and they provide all of the documentation on how to interface with it so I wrote a
00:04:45.400 library called ARB drone that sends the packets to actually send the control inputs to it and what you can do using
00:04:50.639 adher is actually call into my phone system and fly the helicopter using a telephone it's totally useless but it's
00:04:57.080 really cool another example was an art project there was a couple artists in Montreal who uh
00:05:04.320 I forget the name of the of the show but they actually projected on the side of a building eight stories tall music staffs
00:05:11.120 and and had people just walking down the street be able to call into this thing and interact in real time Press buttons
00:05:16.680 changed the way the music was being played the music was coming out over speakers in the in the courtyard and uh
00:05:21.800 that was done with regular telephones so anybody walking down the street could participate in this giant public art experiment um those are those are
00:05:28.720 examples of thinking outside the box and there are a lot of things that haven't been thought of so this is a pretty exciting place to be where really the
00:05:34.479 sky is the limit so I'll talk for a minute about adher platforms there are lots of ways
00:05:40.240 you can connect into adher from day one we've supported asterisk I'm I'm
00:05:45.319 guessing most of you in here have heard of asterisk yes okay well if you haven't
00:05:50.680 it's an open source PBX uh using adher in astris you have an entirely open source stack everything to get the call
00:05:56.840 in and handle it can be done open source most of deployments of adhesion today are still on asterisk last year Jason
00:06:04.400 geki uh added support to tropo which if you've heard of tropo it's uh it's a competitor to twilio they are both
00:06:10.880 cloud-based communication Services tropo is actually a sponsor of this conference and you can use tropo to
00:06:17.440 connect into adher and handle your calls that way I think one of the best Arguments for tropo is especially for people who aren't familiar with Telecom
00:06:24.520 it can be a challenge to set up I'm being a little bit subtle there but with trop you can go to the web page sign up
00:06:31.120 for an account allocate a phone number and within 5 or 10 minutes you can be processing calls through adher so it's a
00:06:36.800 great way to get started if you're looking for something simpler and don't want to go through the hassle of setting up your own
00:06:42.319 asterisk this year we added support for a new platform called prism and prism is kind of at the other end of the scale
00:06:47.919 it's a Enterprise grade system uh prism has been known to scale up to as many as 5,000 concurrent calls so it's really a
00:06:54.840 different class of system uh we are targeting prism full prism support for adher 2.0 which is due later this year
00:07:01.919 but that really gives a nice range of of platforms so you can prototype your app on tropo you can migrate to astris if
00:07:08.160 you need to keep something in house and then go all the way up to prism with little or no changes to your code so it's a very it's a very flexible
00:07:15.759 platform also talk quickly about the architecture of adhesion at the top you
00:07:20.840 have the three telephony platforms you have these are the ways the calls get into your application um these are where
00:07:27.240 the phone numbers ring so Hall goes in uh then those the platform Astros prism
00:07:32.280 or tropo will make a connection into adhesion and then adhesion you can do
00:07:37.639 things like answer the call hang up the call transfer the call all the things that you would need to do with the call
00:07:42.879 adhesion then has built-in support for uh SQL databases using active record for
00:07:49.240 ldap using active ldap for xmpp and jabber which is a which is actually really cool you can mix in presence
00:07:55.759 information so you can know if someone is at their desk or they've stepped away before even send them the call or you
00:08:01.319 can send them a message and of course anything Web 2.0 anything that has an API you can you know a lot of you out
00:08:08.240 there I'm sure you're web developers so being able to access web apis is probably second nature and again this is
00:08:13.800 all ruby so if you need more functionality there's more than likely a gem for it just install the gem you can
00:08:18.840 bake that into your application so I'm guessing that some of
00:08:24.479 you out there especially those of you who didn't raise your hand when you when I asked if you knew what Astros was have this feeling about telephony that it's
00:08:31.240 hard and adhesion can make it a lot less hard so to to kind of reassure you a
00:08:37.039 little bit I'm going to put you back in the comfort zone it's Ruby code it's easy U ad here and provides a DSL domain
00:08:44.039 specific language and you can do things like answer uh if you want to play a text
00:08:50.440 string render it through text to speech you just say speak and you pass it a string you can see on the third line we're looking up the caller ID finding
00:08:57.360 out who that person is looking up their record in the database speak another message to them and then dial so it's very it's very easy to read
00:09:04.920 it's very rubish if you're familiar with that all right so the name of this talk
00:09:11.480 is evented telan applications uh telan application design so let's talk about why
00:09:17.240 evented telefony needs are very well modeled by event evented design um
00:09:23.440 unlike a web page where you have a single loaded teleph a telephone call lasts for an amount of time you've got
00:09:28.800 interactivity for that whole time um many events come out of come out of that phone call for example key presses DTMF
00:09:36.120 every time the user presses a button on their phone we will raise an event with an adhesion and you can react to it and
00:09:41.320 do something with that event uh anytime a new call comes into the telephony platform you'll get a new call event
00:09:48.920 anytime that call changes state so if it goes from ringing to answered or answered to on hold or on hold back to
00:09:54.959 you know up and then to hang up you'll get events for each of those and be able to react to them update build whatever you need to do as the state
00:10:01.880 changes you'll also get events for joining and leaving conference bridges for callers entering the queue being
00:10:07.519 connected to an agent um also interesting our in conferences are active speaker notification so if you're
00:10:13.120 building a web application that needs to be able to see which callers in the conference are actually speaking to make a for a nicer user interface you can get
00:10:19.920 events for those as well so what all this does is allows you to write the main body of your code in a
00:10:26.279 linear fashion something that's very comfortable and familiar um but you can add extra functionality without
00:10:32.079 interrupting that flow so for example in the uh in the example of a conference
00:10:37.399 when the caller joins the conference that's a blocking call right so the the code is going to pause at that point and
00:10:42.800 it won't execute anything after that point until the user exits the conference but let's say for example you
00:10:48.600 want to allow them to press zero to reach an operator or press star to leave the conference you can use a an event to
00:10:55.279 capture that DTMF and then take the caller out of the conference or transfer them really makes that a lot
00:11:01.040 easier you can also react to external events so for example if a timer expires if this is a calling card application
00:11:06.519 you can terminate the call and tell them their balance is out and they need to you know reup it or if you're building a
00:11:12.000 queue you can you can react to a an agent becoming available and then transferring the call taking it from on
00:11:17.680 hold and sending it to the agent so evented makes a lot of sense in in the telepan world so now what I want to show you is
00:11:25.120 how this actually looks in code
00:11:34.680 pull my
00:11:40.240 notes all right so the first thing we'll do I have adher installed I'm not going to go through a gem install I'm sure
00:11:45.959 you've all seen gem install before the name of the gem is adher so just install that Gem and since it's a framework
00:11:51.880 similar to rails we're going to create a skeleton application oh sure thank
00:11:57.399 you how's that more all
00:12:02.600 right good okay all right so we're going to create a gem I'm sorry we're going to create an adher in project and we'll
00:12:09.000 call it Ruby comp so this will lay out the skeleton
00:12:14.320 of your new application and you can see it created a bunch of files we'll go into the Ruby
00:12:20.800 comp application uh the first thing we'll need to do is tweak the
00:12:26.120 configuration the the uh generated do
00:12:33.800 this how's that is that readable okay good um the generate configuration comes
00:12:39.199 with lots of comments I'm not going to go into all this right now I'll be happy to answer questions afterward there are a couple things we want to do for the
00:12:44.399 purpose of this demo I'm going to change the log level to debug just make it a little easier to see what's going on and
00:12:50.519 I'm also going to tweak the configuration for the version of Asis that's running uh unfortunately we try
00:12:55.959 to detect as much of this as possible there are some limitations of the astris platform that you have to actually configure so it's important to check
00:13:02.079 this file whenever you you generate a new project the other thing I did here is I uncommented the line that says
00:13:07.360 enable Ami so in the asterisk World there are two interfaces to dealing with the call you have AGI which is the
00:13:13.920 Gateway interface that's what allows you to do interactive control things like play a sound file hang up a line dial
00:13:20.480 out that's interactive Ami is the manager interface that allows you to take those events asynchronously so the
00:13:26.160 two can work together uh to enable events you need to uncomment the Ami line here of course there username and
00:13:33.040 password I've just got it default for now um in the rest of this file there are other things that you may find
00:13:38.519 interesting for example drb if you're familiar with distributed Ruby it's an RPC mechanism we use drb a lot actually
00:13:45.279 to enable things like click to call if you have a rails application and you want to enable the functionality of a user to click something on your site and
00:13:51.199 receive a phone call drb would be a good way to do that you can also
00:13:56.360 enable you can also enable rails integration this is what I mentioned earlier where it will load in your entire rails environment so you'll get
00:14:02.839 access to all your helpers all your models all that code you've invested why not reuse it build it into your telephony
00:14:08.399 app you also have access to if you're not using rails you can enable active record directly so you can load those
00:14:13.560 database models uh you can enable ldap and xmpp as I mentioned earlier so those three changes there are
00:14:21.040 the uh log level and the enabling asterisk I'm going to leave those that's all we need for now next thing we want
00:14:26.480 to take a look at is the dial plan
00:14:37.199 so the dial plan this is where calls will initially come in when they hit your adher application uh these are
00:14:43.199 these are little named blocks you can actually route calls to different blocks in this case we're just going to use the adher block uh the example starts a
00:14:49.920 Simon game which is a little game you can play on the telephone but what I want to show you is um we're going to
00:14:55.600 basically answer the line and drop the caller into the conference so we'll answer we'll play a sound
00:15:04.959 file so the the caller will here you are now being placed into the conference and then we will actually drop
00:15:11.240 them into the conference application and we'll join the room
00:15:16.360 rubycon now that last line that execute is blocking as I mentioned you're not going to go any further until the user
00:15:21.600 exits the conference so I'll just drop a log statement here
00:15:30.040 of course that won't appear until the color exits or hangs up yeah did you have a
00:15:41.639 question I'm sorry that's that is a good point so you do have to also configure Astros to load the adhesion app let me
00:15:47.560 um me jump over to what that looks
00:15:55.000 like so this is a little bit beyond the scope of where I was planning to do today but it's it is a good point
00:16:04.000 um extensions.com you can see the at the end there we have all the calls routed
00:16:09.519 to AGI this is what actually sends the call from asterisk into adhesion um the asterisk setup is is a bit beyond the
00:16:15.920 scope of this talk but we do have on the adher website and on the moo lingo blog we have screencasts and examples to help
00:16:22.000 you get to this point it's also interesting to note that some of this stuff does not apply at all when you're using tropo because there is that
00:16:28.000 configuration isn't required but it is a good point thanks for mentioning that okay so um we did look at dial plan
00:16:36.040 we have those three lines um so now let's take a look at the evented side of it we're going to have events.
00:16:43.720 RB so this is the skeleton events. RB that you get when you generate a new
00:16:49.079 app the first thing I want to do is pull in a
00:16:54.880 class use something I prepared earlier so this is a a class now it's important to note that you are writing threaded
00:17:01.560 code so you'll need to take care to make sure that you don't do anything that's going to break in a in a threaded world
00:17:07.039 what we're going to do is create a class called conference and this will be used to manage users entering and leaving the conference we're going to include
00:17:13.240 Singleton so there's only one instance of the conference at any given time and when the conference is initialized we'll
00:17:18.720 keep a list of the participants the uh this little piece at the bottom is just a little syntax sugar so we can not have
00:17:23.880 to call instance on it so the next thing I want to do is pull in a couple
00:17:30.200 methods that will handle what happens when a user enters the conference or leaves the conference the first is ADD
00:17:36.200 participant we're going to call it with the channel ID and again that synchronized block is a mutex to make
00:17:41.480 sure that we don't accidentally have two threads trying to add to the same array at the same time avoid that race
00:17:47.080 condition and the same is true with remove participant we want to pull them out of that
00:17:54.000 array the next thing we want to add is a bit of code
00:18:01.280 that will play a sound so we've got a list of the participants in in the chat in the conference brid at any given time
00:18:07.000 now we want to be able to play a sound file to them this will go iterate over that list and add a a log message saying
00:18:13.640 that we're playing a sound file to the channel and then actually send the event to asterisk to play that sound
00:18:20.200 file so now we have the code to actually do these pieces now we need to add some code that will handle the events coming
00:18:26.520 out of ader
00:18:34.840 all right so we're going to have events this events. manager
00:18:43.240 asterisk manager interface each so this block will be
00:18:49.840 invoked each time an event is raised coming from from asterisk we'll call that event
00:19:01.080 all right so the first thing we'll do is grab a handle on the manager interface that's what we'll use to send commands to the asterisk server we'll grab the
00:19:07.840 channel so the event has several headers that include the channel uh the caller ID the unique ID of the call things to
00:19:14.039 help you figure out what event and what channel you're dealing with and then we have a case statement to to determine
00:19:19.840 which event we've received so I've got two added here the first is conference join we will get that event each time a
00:19:25.440 caller joins the conference and the next one is conference leave which will will get every time the user exits the
00:19:32.480 conference all right so that should be enough to test so let's pull up the app
00:19:38.840 the uh this is a blink which is a soft phone start
00:19:49.159 asterisk all right asterisk is up and let me place the call so if we oh
00:19:55.080 I need to start adher too that would be important
00:20:02.280 so I've got aderson running in one window and Astros one running in the other um we care more about it here is in the Asis right now so when I call the
00:20:08.600 conference Bridge what should happen is first the dial plan will execute so we'll get the message you now you're about to be placed in the conference
00:20:14.760 you'll then join the conference what will then happen is astris will send an event to adher and we will get the conference join event and if we did it
00:20:21.480 right we'll also hear a sound that sort of sounds like a clanging of pans that you've entered the conference
00:20:29.799 you will now be placed into the conference and there you go so that's
00:20:35.600 that's just a conference joint event um the conference application that I'm using does not include any sound effects
00:20:40.799 by default so that's actually a good way to let people know that people are entering or leaving the bridge yes you have a question yeah basically this is
00:20:47.600 this is mostly command and control you're teaching us right now but what part of the API handles the text to
00:20:53.600 speech a is it dictionary based and B how does it handle n where you've got
00:21:00.159 different languages okay um if you don't mind let me cover that in the Q&A at the end the questions about text to speech
00:21:05.600 I'll be happy to get to that okay um so the recording you're going to hear right now is all pre-recorded just for the
00:21:11.240 record it's not text to speech at the moment okay so we've got the call on the conference it's kind of boring um I'm
00:21:16.480 guessing you guys have heard of soundboards on the internet like uh the Chuck nor soundboard or the Terminator soundboard um a way to play funny sound
00:21:23.080 files so let's do one of those all right first thing we're going to do is add another event
00:21:30.760 Handler so this is going to be the DTMF event every time the caller presses a button on their phone we want to capture
00:21:37.679 that and react to it so the DTMF event there you get two you get one on the
00:21:42.960 beginning of the DTMF in other words when the user presses the button in other words starts pressing the button and then when they let go you get a
00:21:48.640 second that's important because if in the uh example the helicopter I mentioned earlier to fly the helicopter
00:21:54.799 I determine how long the helicopter is tilted by how long the button is held down so these the timing of the events
00:21:59.840 can be significant in this case we only care that a button was pressed so we're going to capture one of the events in this case you can see in the uh the if
00:22:06.720 statement here we want to look only for end events that are set to yes the other thing we care about is that we get the
00:22:12.559 digit out of the event so that's uh sent as from the in as part of the header sent from
00:22:17.760 asterisk so now that I've got that method let's define we we've asked for a play play for DTMF method let's go make
00:22:23.679 sure that method is available in the conference class um actually first let me grab
00:22:29.159 the list of sound files all right so we've got six
00:22:35.120 hopefully humorous sound files here and I'm going to pull in also the uh the method to play
00:22:42.799 DTMF all right so play for DTMF is just a real thin wrap around play sound it's going to map the digit that was pressed
00:22:48.760 to the audio yes thinking so you can you capture the
00:22:57.279 while you're pressing or you have to press the release and then you meure okay so the question was Can you
00:23:04.120 capture the information while it's being pressed yes you can so you the first
00:23:09.600 event you will get for asterisk is when the button Goes Down And while the button is down you you've received the
00:23:15.159 event the next event you'll get is when the button comes up so you'll get both in this case we're only looking for the
00:23:21.320 end event but you could look for the begin and and do something while the DTM is coming in
00:23:31.960 right so in the helicopter example when the begin event comes in I tilt the helicopter forward and when the end
00:23:37.039 event comes in I put it back uh in this case we only care about the end event because we only want to
00:23:42.880 know that a button was pressed so I've added the event handler for the DTM I've added a method that will play the sound
00:23:49.480 file so let's test this I do need to restart
00:23:54.679 adhesion because I've changed the event handlers
00:23:59.720 so I've restarted it you will now be placed into the conference all right so we have a list
00:24:06.480 of sound files here does anyone want to pick which one we're going to play first from this list Shout It Out
00:24:14.080 weasel whoops weasels are good it's at one
00:24:19.320 weasel have eaten our phone system any
00:24:34.600 six everybody
00:24:39.640 loves I should have
00:24:46.679 mentioned all right all right let me come back to that so you can see here we'll come back to five you can see here
00:24:53.320 in the log we got our event you can see the channel that triggered the event so we know who to blame for playing monkeys
00:24:59.039 at us we can see the unique ID of the call which may be interesting for logging purposes you can see which digit
00:25:05.159 was pressed in this case the DTMF was coming to us as opposed to sending DTMF out and you can see here they begin and
00:25:12.399 end in this case we this is not a begin this was an end so that's an example of just using
00:25:19.279 DTMF now let's see how to view uh so so you can see an example of I've only
00:25:26.240 picked three events here you might be wondering what other events are possible there are two ways to answer that question one is the documentation if you
00:25:32.520 go to wiki. as.org you'll be able to see a whole list of various applications
00:25:37.640 that generate manager events um but sometimes even that's incomplete so the
00:25:42.720 one easy way to see what's going on is to actually go back up to this event handler and just log in this case I'm
00:25:48.919 going to log the name of the event coming to
00:25:54.600 every event that comes in I'm just going to log it at the info level received Event Event
00:26:02.399 name all right and I'm going to turn up the logging
00:26:08.360 to info just to make it a little quieter and we'll try this call again you will now be placed into the
00:26:16.440 conference oh I have to
00:26:25.320 restarter okay so the first one you can see is we received the fully boost event that lets us know that asterisk is ready to take calls which it already was but
00:26:31.840 it sends it to us anyway you will now be placed into the conference all right so we have a bunch
00:26:37.520 of interesting events here we have new channel which lets us know that a call has come in we have some VAR set which is an internal asterisk Channel variable
00:26:44.960 we have new state which is telling us that we are transitioning to from ringing to answered actually that's
00:26:50.039 transitioning to ringing and then we have another one here that's transitioning ringing to answered we have an event uh here that the caller
00:26:57.440 joined the conference and another event here so you we played that sound file that that can sounding
00:27:03.640 sound file when that completes the conference Bridge send us another event saying the sound file is complete so if you needed to play another sound file
00:27:09.960 you could do that these other events here are internal to asterisk um in this case they show us call Quality
00:27:16.320 information so what was the other event you wanted to uh was it five you said five all right let's play five go and bu
00:27:22.480 your bottoms you silly English kots I fart in your G Direction your
00:27:29.720 mother was a hamster and your father smelled of elderberries now go away or I
00:27:35.600 shall taunt you a second time can't go wrong with myy
00:27:41.320 python yes a question can you filter the events that you're getting from asterisk or is All or Nothing so right so the
00:27:48.799 question is can you filter the events that are coming from asterisk as of today well there are two answers to that question astris does
00:27:55.000 allow you to put filters on the events you subscribe to adhesion doesn't expose that we'd rather
00:28:00.720 get all the events and filter in our code uh as of adhesion today adhesion 1.x you you basically do it in that case
00:28:07.840 statement that I showed you so what I typically do is I have a case statement that dispatches to the various methods that do whatever I need to for that
00:28:14.360 event
00:28:23.120 and so will the number of events become a problem as you scale and yes it is possible um so there are different there
00:28:29.159 are different strategies you can as I mentioned filter the events based on uh you know if you need to you could have
00:28:34.480 multiple adher servers and have this one only handling certain types of events there are different ways to deal with that um also in in adhesion two we will
00:28:41.480 add the ability to do guards if you're familiar with erlang um something BL does as well so you can subscribe to
00:28:47.840 certain types of events and just not enter that block at all yeah but so but right now the answer
00:28:54.000 is you pretty much do it yourself and C
00:29:01.919 um yes so the question is how different are the various platforms astris versus prison versus tropo um if you don't mind
00:29:08.480 let me come back to that one because that's a good question all right so we've we've got all the events oops we
00:29:15.279 got all the events uh that are coming from astr so you can very easily see which events it's throwing out there are a few events that are also generated by
00:29:22.600 the framework itself um they're documented here in the generated events.
00:29:27.640 RB those are for example events. exceptions so every time your application hits an
00:29:33.200 unhandled exception it will raise this event this is helpful for example uh
00:29:38.960 this is what we use to send exceptions in our application to air bra we attach a event handler on the exception the
00:29:45.679 exception events and then send it off to air braak's API there are other events uh manager interfaces when we just
00:29:51.159 demoed after initialized is called after the adhesion framework has finished booting it's connected to all the back
00:29:56.559 ends it's ready to process calls you can use that to do something if you need to uh events. shutdown is the opposite as
00:30:02.799 ader in starting to shut down you'll get this event asterisk before call and after call which isn't mentioned here uh
00:30:09.919 when the call comes into asterisk before dial after the call is connected to adhesion but before the dial plan code
00:30:15.480 starts executing you can do something with that event the failed call is when a call has been generated to go outbound
00:30:22.840 so the way that works is we tell astris to place a call and then when it connects it sends the call into adhesion
00:30:29.240 if that call fails for some reason if it doesn't answer or gets a congestion or busy signal or something then the call
00:30:34.640 will never come into adhesion so that event will allow you to handle outbound attempts that fail and then hung up call
00:30:40.480 of course is triggered whenever a call hangs up um yeah okay so that's these are the
00:30:46.360 building blocks for evented design as I mentioned I think the real power comes from combining evented with the
00:30:51.880 procedural code you do in dial plan um if you're interested in more information about all of these things we have well
00:30:58.039 two things the first I want to tell you about is AD hear in C next week next
00:31:04.240 week the eth 9th two weeks one week one week next week lost track all time next
00:31:11.000 week is adher comp uh thanks again to our sponsor tropo adher comp is a free event if you can find yourself in San
00:31:16.480 Francisco next week I think we have something like 20 seats left so if you're interested definitely come out uh
00:31:22.360 I'll be there the entire adhesion core team will be there we will have presentations from people doing interesting things with adher
00:31:28.639 should be should be pretty cool and I also want to mention that our website ad.com has links to uh documentation our
00:31:36.000 Wiki is is there our mailing list is there IRC we have a really a really good community and um definitely if you have
00:31:42.200 questions we'd like to help that out also the Modo lingo website our Blog has a lot of tutorials screencasts things
00:31:47.440 like that that'll help you get started with adher so let me go back to the questions I know there were two of them
00:31:53.039 um the first was about text to speech okay so the answer on text to speech is
00:31:58.360 it is platform dependent um you asked about things like internationalization so for example
00:32:04.279 tropo supports 24 languages is that right 24 languages you have to declare
00:32:10.279 which language you want and you have to pass in the localized string but tropo
00:32:15.399 support you'll be able to do text to speech generation in 24
00:32:23.200 languages so the question is is it dictionary based or phonetically based and I don't know the answer to that
00:32:52.080 so the answer is it synthesized and Chris also made a good point it does support ssml so there's a companion Library called Ruby speech that will
00:32:58.159 allow you to generate ssml documents which is speech synthesis markup um you do it in a ruby way it's it's actually
00:33:03.960 inherits from noi so you can generate these documents that will allow you to control how the text of speech is
00:33:09.120 generated control the procity which is the rate of speech the inflection the gender all these all these things and
00:33:15.200 then one more question over here remind me your
00:33:22.159 question right okay so the question is uh really I think it's a question of how the different platforms are supported by
00:33:28.679 adher um the code is is is your code portable across platforms today mostly
00:33:35.200 yes the notable exception is events with adher 1.0 the only really support the
00:33:40.720 only real platform that supports events properly is asterisk um partly that's because tropo today does not have an
00:33:47.200 Eventing model that that works this way um in adher 2.0 which is targeted for later this year uh the Eventing model
00:33:54.080 will be unified between asterisk and prism which is and actually tropo will
00:33:59.679 eventually also be running on prism so all three platforms should have uni uniform event support across all three
00:34:05.919 now there will always be cases where platforms have support that others don't so for example today asterisk supports
00:34:11.800 video calls and a A Primitive video conferencing bridge tropo and prism won't if you want to use that
00:34:17.200 functionality you can but you just have to know you won't be portable and we'll have documentation to help you figure out where that is but for the most part
00:34:23.399 I would say 90% of applications can be ported without any code change at least today between Asis and
00:34:30.839 TR okay so the question was how uh how is the application laid out so you can add pieces on and and where the where
00:34:37.800 the various pieces belong within the application uh and I and he he makes a good point I did put everything in one file that was really just for Simplicity
00:34:44.119 um normally what you would want to do is have a subdirectory maybe a a library directory and put libraries in there
00:34:51.200 that you can invoke from whether it's dial plan or events and you know load them in um there's not a library
00:34:57.200 directory here um just because I haven't created one yet the other answer is components so components are a plugin
00:35:04.880 for adhesion and they're redistributable you can get them as Gems or you can copy the directory into the adher application
00:35:10.680 so a component let me show you an example component the uh one we comes with Simon
00:35:16.240 game for example so Simon game at the very top we have methods for dial plan so this says
00:35:23.000 that this component is only to be used in the dial plan context that's because sometimes something that makes sense in
00:35:28.720 a procedural world doesn't make sense in an Eventing world so in this case Simon game is only meant for dial plan and
00:35:34.760 then what that does is it just invokes the new a new instance of the Simon game class and runs it with the start method
00:35:41.359 um so then down here you have the Simon game um all the various methods that go with it and by putting it into a
00:35:48.040 component or by putting it into a library it makes it possible to test so we're big on test driven development so
00:35:54.720 all the stuff that we write we have to have a way to test and that's components are good way to do that as our libraries
00:36:00.119 or helpers um dial plan. RB currently is not testable so really the purpose of
00:36:05.440 dial plan. RB is to help people who come from the astris world who aren't really rubyists we're going to be looking at ways to simplify that for adher 2 but
00:36:12.160 that's not totally flushed out yet other question
00:36:20.839 here so the question is are there any projects on GitHub that show integration with Spinx not that I know of
00:36:28.079 um I can tell you that the other so the Ruby speech library that I mentioned earlier will generate ssml and grxml uh
00:36:34.359 Sphinx for those of you who don't know is a text uh is a speech recognition engine an open source one done by Carnegie melon and you need to so
00:36:41.880 asterisk doesn't support it out of the box you would have to compile that and integrate it um unfortunately I don't
00:36:47.599 know of any other box yes
00:36:56.520 question so the question was we at one point there was talk of support for free- switch in adhesion and how is that
00:37:02.640 coming along um the blunt answer is that we haven't had a project that needed it
00:37:07.680 yet but there is good news so part of the work that we've done with adher 2.0
00:37:13.000 has been adher 1.0 was really very asterisk specific in fact the way tropo
00:37:18.119 supports adhesion 1.0 is to emulate asteris it actually has an AGI emulation
00:37:23.800 layer um that's not ideal so for adher 2.0 we've actually restructured a lot of the internals and gotten rid of the
00:37:29.880 specific asteris dependencies um and we've separated it into two layers adher the framework will remain the framework
00:37:36.560 for building voice applications it's the easy way to get that high level functionality we've abstracted all of the um lower level platform support into
00:37:44.000 a library called punch block and punch block will allow you to talk to today uh prism tropo and asterisk and because
00:37:51.480 we've done that hard work of right so free switch support we're optimistic should be a lot easier to add now
00:37:58.160 but we would like to support free switch we just haven't needed it ourselves yet yep so any other questions on
00:38:06.800 this no okay well as I mentioned um the adhesion website is a great resource and
Explore all talks recorded at RubyConf 2011
+55