SlideShare a Scribd company logo
Real time voice call integration - Confoo 2012
WHAT’S IN STORE

•
•
•
•
    •
    •
    •
•
Live Coding
Live & Semi-live Demos
MICHAEL PEACOCK
SMITH ELECTRIC VEHICLES
NO. NOT MILK FLOATS
    ALL ELECTRIC, COMMERCIAL VEHICLES.                                      (ANYMORE)




Photo courtesy of kenjonbro: http://www.flickr.com/photos/kenjonbro/4037649210/in/set-72157623026469013
ALL-ELECTRIC COMMERCIAL VEHICLES
TELEPHONY INTEGRATION

•
    •
    •
    •
    •
    •
•
    •
    •
TELEPHONY INTEGRATION

•
    •
•
    •
    •
    •
MY FIRST EXPOSURE AS A DEVELOPER

•
•
    •

    •
    •
•
    •
    •
PROVIDERS
TWILIO VS TROPO
Twilio                                      Tropo
30$ Free Credit                             Free for development
                              Incoming and outgoing calls
                           Send and receive SMS messages
                            IVR: Interactive Voice Response
                              DTMF: Record key presses
                                 Number provisioning
                      Open VBX (Twilio project, with a Tropo fork)
Twimlets                                    File hosting
Connect: for apps                           SIP: Additional Integration
iOS Integration                             W3C: Speech Recognition Grammar
Browser Integration                         IM Service integration
WHY?



•
•
WHY: CUSTOMER SERVICE
•
    •
        •
    •
    •
        •
        •
        •
•
    •

        •
WHY: LEAD TRACKING

•
    •

    •
    •

    •
    •
WHY: VERIFICATION & SECURITY

•
    •
        •
    •

•
    •
•
    •
WHY: MARKETING

•
    •
HOW? INBOUND CALLS
•

•


•



•
XML
HOW: OUTBOUND CALLS

•

•

•
Rest
POST/GET
XML
XML: HEADER AND WRAPPER

•
•
• <Response>
  •
Real time voice call integration - Confoo 2012
XML: PLAY

• <Play>
   http://url-to-an-audio-file
</Play>
  • loop
PLAY / HOLD

•
•
XML: ASK

• <Gather>
  •   action
  •   method
  •   timeout
  •   numDigits
  •   finishOnKey
XML: RECORD

• <Record>
  •   action method timeout   finishOnKey
  •   maxLength
  •   transcribe
  •   transcribeCallback
  •   playBeep
TRANSCRIPTIONS

•
•
•
•
    •
    •
    •
XML: SEND A TEXT

• <SMS>
  •   to
  •   from
  •   statusCallback
  •   action    method
XML: TRANSFER THE CALL

• <Dial>
  •   action method   timeout
  •   hangupOnStar
  •   timeLimit
  •   callerId
•
• <Number>, <Client> <Conference>
MORE XML

• <Hangup>
• <Redirect>
• <Reject>
• <Pause>
XML IS GOOD...BUT...

•

•


•


•
    •         
HOW: REST

•
    •
    •
    •
    •
•
    •
•
    •
SECURITY

•

•

•

•
    •
Real time voice call integration - Confoo 2012
SANDBOX

•
•
•
•
•
•
Real time voice call integration - Confoo 2012
HOW MUCH?
                    Twilio          Tropo
Phone Numbers       $1/month        $3/month
Inbound minutes     1c              3c / minute
Outbound minutes    2c              3c / minute (international+)
Toll free numbers   $2/month*       $5/month*
SMS In              1c              1c
SMS Out             1c              1c
MY APPLICATIONS

•
    •

    •
    •
    •
•
    •
        •
        •
WHY YOU MIGHT WANT TO USE IT
WHAT WE ARE GOING TO BUILD

•
    •
    •

•
•
PHONE NUMBER VERIFICATION
PNV: GET THE DETAILS
PNV: CREATE THE UN-VERIFIED USER
// unverified user; default verified status of false
$user = new UnverifiedUser();

$user->setFullName( $_POST['full_name'] );
$user->setFullPhoneNumber( $_POST['number'] );

$user->generateRandomVerificationCode();

$user->save();

$userID = $user->getID();
PNV: MAKE THE CALL
$twilioClient = new Services_Twilio( $sid, $token );

$call = $twilioClient->account->calls->create(
   $ourPhoneNumber,
   $countryCode . $telephoneNumber,
   'http://my-url/verify/&user=' . $userID
);
PNV: ASK FOR MORE
// create a response / twiml object
$response = new Services_Twilio_Twiml();

$gather = $response->gather(
   array( 'numDigits' => 4,
          'action' => $url . '/verify/' .
                      $userID       ) );
$gather->say('This is the ' . $siteName . '
              telephone verification service.
              To verify your telephone number,
              please enter the four digit code
              shown on your screen now.');
print $response;
PNV: VERIFY
$code = (int) $_REQUEST['Digits'];

if( $user->getVerificationCode() == $code )
{
   $user->verify();
}
else
{
   $this->askAgain();
}
PNV: ASK AGAIN

$gather = $response->gather(
  array( 'numDigits' => 4,
         'action' => $url . /verify-
                   again/' . $userID ) );

$gather->say('Sorry, the code you entered
              was incorrect, please try
              again.');

print $response;
PNV: VERIFIED

$response->say('Thank you, your phone
                 number has been
                 verified');
print $response;
HEARTBEAT

•
    •
Real time voice call integration - Confoo 2012
LEAD TRACKING
LEAD TRACKING: NUMBER PROVISIONING
$twilioClient = new Services_Twilio( $sid, $token );
// search for a local canadian number
$numbers = $twilioClient->account->available_phone_numbers->getList('CA', 'Local');
if( count( $numbers->available_phone_numbers ) > 0 )
{
     // buy the first we find
     $purchased = $twilioClient->account->incoming_phone_numbers-
     >create(array('PhoneNumber' => $numbers->available_phone_numbers[0]->phone_number
     ));

       $advert->setPhoneNumber( $numbers->available_phone_numbers[0]->phone_number );
       $advert->setPhoneNumberSid( $purchased->sid );
}
else
{
       throw new Exception('No numbers available');
}
LEAD TRACKING: POINT THE NUMBER
$purchased->update(
   array(
      'FriendlyName' => 'Lead tracking for
                          Michaels advert',
      'VoiceUrl' => 'http://my-application-
                     url',
      'VoiceMethod' => 'POST‘
   )
);
NEWLY PROVISIONED NUMBER
LEAD TRACKING: INBOUND CALLS

•

$dialledNumber = $_POST['To'];
CALLER ID?
LEAD TRACKING: MAKE A CONNECTION

•
    •
    •
    •
    •
LOOKUP THE NUMBER
LOG THE LEAD
TRANSFER THE CALL

$response = new Services_Twilio_Twiml();

$response->dial( $advertisersNumber,
array('callerId' => $ourVerifiedNumber )
);

print $response;
APP: CONFERENCE SESSION FEEDBACK

•

•
Real time voice call integration - Confoo 2012
LIVE DEMO: YOUR TURN
APPS: CONNECT

•
•

•
    •
    •
    •
BROWSER: CLIENT

•
    •
    •
•
    •
Real time voice call integration - Confoo 2012
MOBILE

•
•
    •
    •
•
TWIMLETS

•
    •
    •
OPEN VBX
A LOOK BACK AT TROPO

•
    •
        •
        •
    •
TROPO: W3C: SPEECH RECOGNITION
                  GRAMMAR



•
    •
    •
    •
•

•
    •
W3C SPEECH RECOGNITION GRAMMER

•
•

•
BASIC SPEECH RECOGNITION

•
TROPO: SIP INTEGRATION

•
    •
    •
WHICH TO USE

•
    •
        •
        •
        •
    •
        •
        •
•
FINAL THOUGHTS
DEMO APPLICATIONS

•


•

•
THANKS & QA

More Related Content

PPTX
Dealing with Continuous Data Processing, ConFoo 2012
PDF
Symfony components in the wild, PHPNW12
PDF
Symfony War Stories
KEY
Phpne august-2012-symfony-components-friends
PDF
Design how your objects talk through mocking
PDF
Advanced symfony Techniques
PDF
Symfony 2 (PHP Quebec 2009)
PDF
Decoupling the Ulabox.com monolith. From CRUD to DDD
Dealing with Continuous Data Processing, ConFoo 2012
Symfony components in the wild, PHPNW12
Symfony War Stories
Phpne august-2012-symfony-components-friends
Design how your objects talk through mocking
Advanced symfony Techniques
Symfony 2 (PHP Quebec 2009)
Decoupling the Ulabox.com monolith. From CRUD to DDD

What's hot (20)

PDF
Symfony 2.0 on PHP 5.3
PDF
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
PDF
The IoC Hydra
PDF
Beyond symfony 1.2 (Symfony Camp 2008)
PDF
The IoC Hydra - Dutch PHP Conference 2016
ODP
Rich domain model with symfony 2.5 and doctrine 2.5
PDF
Forget about index.php and build you applications around HTTP!
PDF
News of the Symfony2 World
KEY
Perl Web Client
ODP
Symfony2, creare bundle e valore per il cliente
PDF
Design Patterns avec PHP 5.3, Symfony et Pimple
PDF
Nubilus Perl
PDF
Symfony2 revealed
PDF
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
PDF
Decoupling with Design Patterns and Symfony2 DIC
PDF
Forget about Index.php and build you applications around HTTP - PHPers Cracow
PDF
Doctrine fixtures
PDF
Silex meets SOAP & REST
KEY
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
PDF
Dirty Secrets of the PHP SOAP Extension
Symfony 2.0 on PHP 5.3
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
The IoC Hydra
Beyond symfony 1.2 (Symfony Camp 2008)
The IoC Hydra - Dutch PHP Conference 2016
Rich domain model with symfony 2.5 and doctrine 2.5
Forget about index.php and build you applications around HTTP!
News of the Symfony2 World
Perl Web Client
Symfony2, creare bundle e valore per il cliente
Design Patterns avec PHP 5.3, Symfony et Pimple
Nubilus Perl
Symfony2 revealed
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
Decoupling with Design Patterns and Symfony2 DIC
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Doctrine fixtures
Silex meets SOAP & REST
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Dirty Secrets of the PHP SOAP Extension
Ad

Similar to Real time voice call integration - Confoo 2012 (20)

KEY
Getting Started with Twilio
PDF
Greach 2011 - Building Telephony Apps with Groovy and Grails
PDF
Ruby on the Phone
PPT
VoIP Drupal Framework DrupalCon Prague
PDF
7 Principles of API Design - Waza
ODP
Otra forma de hacer aplicaciones de telefonía
PDF
Look Who's Talking
PPTX
Supermondays twilio
PDF
Globe Labs - Voice API (Developer Preview)
PPT
VoIP Drupal: building sites that send SMS, answer phone calls, and more
PDF
Phone calls and sms from php
PPTX
Tech campmemphis slides_post_session
PDF
Tropo Presentation at the Telecom API Workshop
PDF
2015 ZendCon - Do you queue
PDF
TwilioCon 2013 - Communications Without Boundaries
PPTX
DevNet @TAG - Spark & Tropo APIs - Milan/Rome May 2016
ODP
Developing a Public API -- at ILTechTalks 2015
PDF
Twilio - Social App Workshop - 2010-07-24
PPTX
eMetrics Stockholm - What the F*** is wrong with my conversion?
KEY
Tropo: Telephony in the Cloud
Getting Started with Twilio
Greach 2011 - Building Telephony Apps with Groovy and Grails
Ruby on the Phone
VoIP Drupal Framework DrupalCon Prague
7 Principles of API Design - Waza
Otra forma de hacer aplicaciones de telefonía
Look Who's Talking
Supermondays twilio
Globe Labs - Voice API (Developer Preview)
VoIP Drupal: building sites that send SMS, answer phone calls, and more
Phone calls and sms from php
Tech campmemphis slides_post_session
Tropo Presentation at the Telecom API Workshop
2015 ZendCon - Do you queue
TwilioCon 2013 - Communications Without Boundaries
DevNet @TAG - Spark & Tropo APIs - Milan/Rome May 2016
Developing a Public API -- at ILTechTalks 2015
Twilio - Social App Workshop - 2010-07-24
eMetrics Stockholm - What the F*** is wrong with my conversion?
Tropo: Telephony in the Cloud
Ad

More from Michael Peacock (20)

PPTX
Immutable Infrastructure with Packer Ansible and Terraform
PPTX
Test driven APIs with Laravel
PPTX
Symfony Workflow Component - Introductory Lightning Talk
PPTX
Alexa, lets make a skill
PPTX
API Development with Laravel
PPTX
An introduction to Laravel Passport
PDF
Phinx talk
PDF
Refactoring to symfony components
PPT
Dance for the puppet master: G6 Tech Talk
PPT
Powerful and flexible templates with Twig
PPT
Introduction to OOP with PHP
KEY
KEY
Evolution of a big data project
PPTX
Data at Scale - Michael Peacock, Cloud Connect 2012
PPTX
PHP & Twilio
PPTX
PHP Continuous Data Processing
PPTX
PHP North East Registry Pattern
PPTX
PHP North East - Registry Design Pattern
PPTX
Supermondays: Jenkins CI lightning talk
PPTX
Corporate Structures - September 2010
Immutable Infrastructure with Packer Ansible and Terraform
Test driven APIs with Laravel
Symfony Workflow Component - Introductory Lightning Talk
Alexa, lets make a skill
API Development with Laravel
An introduction to Laravel Passport
Phinx talk
Refactoring to symfony components
Dance for the puppet master: G6 Tech Talk
Powerful and flexible templates with Twig
Introduction to OOP with PHP
Evolution of a big data project
Data at Scale - Michael Peacock, Cloud Connect 2012
PHP & Twilio
PHP Continuous Data Processing
PHP North East Registry Pattern
PHP North East - Registry Design Pattern
Supermondays: Jenkins CI lightning talk
Corporate Structures - September 2010

Recently uploaded (20)

PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Electronic commerce courselecture one. Pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Approach and Philosophy of On baking technology
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
A Presentation on Artificial Intelligence
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Electronic commerce courselecture one. Pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Digital-Transformation-Roadmap-for-Companies.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
cuic standard and advanced reporting.pdf
Encapsulation_ Review paper, used for researhc scholars
Approach and Philosophy of On baking technology
Understanding_Digital_Forensics_Presentation.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Network Security Unit 5.pdf for BCA BBA.
A Presentation on Artificial Intelligence
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
“AI and Expert System Decision Support & Business Intelligence Systems”
Mobile App Security Testing_ A Comprehensive Guide.pdf

Real time voice call integration - Confoo 2012

Editor's Notes

  • #2: Good morning, I’m here to talk about how you can integrate real time voice calls and mobile services into your web application.
  • #3: Today I’m going to talk about:Telephony integration the providers availableWhat they offer and how they tend to workSome sample applications:-verify a users phone numberTracking phone leadsAnd providing feedback on eventsI’m also going to talk about how we use it at Smith Electric
  • #4: I’m too much of a wimp to bring any live coding into the presentation however...
  • #5: There are some live and semi-live videos. There were originally three live demos, however my phone doesn’t work here – so two of them are pre-prepared, and one is for you to join in with later.
  • #6: For those of you who don’t know me; I’m Michael Peacock – I’m the web systems developer for Smith Electric Vehicles on their telemetry project. I’m an experienced lead developer, I spent 5 years running a small web design and development firm, writing bespoke CMS, E-Commerce and CRM solutions. I’ve written a few PHP related books, and volunteer with the PHP North-East user group in the UK.You can find me on twitter, or contact me if you have any questions later.
  • #7: Smith are the worlds largest manufacturer of all electric, commercial vehicles. Founded over 90 years ago to build electric delivery vehicles – both battery based and cable based. In 2009 the company opened its doors in the US, and at the start of last year the US operation bought out the European company which brings us to where we are today.
  • #8: Normally when I tell people I work with Electric Vehicles, they think of hybrids like the Prius, or they think about passenger electric vehicles such as the Nissan Leaf. When I tell them its COMMERCIAL electric vehicles, they think about milkfloats or airport passenger buggies.What we actually make are large scale, fully electric delivery and transport vehicles.
  • #9: These vehicles range from depo based delivery vehicles to home delivery vehicles to utility applications, military applications right through to the american school bus.
  • #10: Telephony integration gives us access to a range of features directly in our web applications. When it comes to calls we can:Make callsReceive callsRecord what a user is saying and even transcribe those callsAnd log the key pressesWith SMS and mobile integration we can send and receive text messages (a fairly common service / API now)
  • #11: We can also provision numbers, and work with text to speech, speech to text and different languages, accents and voices.
  • #12: I was first given exposure to integrating calls and texts into websites and web applications six years ago. The first was a gambling website which needed to verify their customers landline phone numbers. They used a complicated and expensive service to get the job done – and all it did was verify the number.Sending and receiving text messages was some what easier, back then it was still a clunky process – now there are many services which offer this. I’m going to be focusing more on call integration.
  • #13: There are two main players in the field:Twilio and tropo; both are good and both are big players – we will review them before diving into building phone powered applications.
  • #14: With both providers its free to get started – either with free credit or with free development environments. They both support the core features such as sending and receiving calls, text messages, IVR menus, recording key presses number provisioning. However they have some pretty key differences; Twilio has browser and mobile integration, as well as the ability to connect to other twilio accounts – allowing you to sell your app, while letting your customer pay for usage; whereas Tropo provide integration with SIP, Instant messengers and can actually process requests based on what the caller says, not just what they press.
  • #15: Why would you want to do this?Most people I talk to say one of two things:Phone integration – wow thats really cool there are loads of things I can do with that- Why would I want to do that?Lets look through some potential use cases.
  • #16: Customer service:Order dispatched- thanks for the order- rate your purchaseWould you like a call back?
  • #17: Tacking leadsLeads which are still based on callsCalling to arrange to look at a used car, you would want to call the owner but the site advertising the car would want to keep track on how useful it was being, while also protecting the seller by not giving out their real phone numberMany big companies use number provisioning for tracking leads. Now we can too.We could even integrate it into a CMS for A/B testing
  • #18: Verify phone numberTwo factor authConfirming critical actions/transaction
  • #25: Say something with the Say tagWe can repeat what we sayEven change the gender of the voiceThe accent of the voiceAnd even the language
  • #26: We can play audio files with the Play tag, supplying the Url to a file,And we can loop the file to with the loop attribute
  • #27: Twilio gives us a whole bunch of creative commons hold music if we want it!
  • #28: We can use the Gather tag to ask the caller a question, then use the appropriate attributes to set:Where to submit the response toHow to send the responseHow long we should wait for a responseHow many digits we are expecting, is this a 4 digit pin or a phone number?And/or should we wait for a specific key press to class the input as over
  • #29: We can also record what the caller says,Action method timeout and finish atributes as before a maximum length of the recording we can opt to have the recoding transcribed and the transcription sent to a callbackUrlWe can even control if the call should play a beep sound before the caller leaves their message.
  • #30: The transcription service brings some caveats:Its a paid for service the maximum duration is 2 minutesThe call back contains the text of the call, if the transcripotion succeeded or failed and the resource properties of the transcription so we can access it using the API later
  • #31: We can send a text message with the SMS tag, specifying:Who to send it to who to send it from (must be verified or owner)A call back for success/failure
  • #32: Within an active call we can dial additional numbersThis can be calling another number, a user using the twilio client, or creating a conference bridge.
  • #33: We also have some tags to hangup, redirect the call, reject the call and pause
  • #34: Being XML based makes it really easy to write apps, but XML is really tedious to write,We dont want it lying around solution: client library; it generates it for us
  • #35: How and why does the rest side of the service work: we use it for phone numbers to:SearchBuyUpdate and delete numbersWe use it to make a callAnd we use it to send a text (independantly, as opposed to within the flow of a call)
  • #36: How can we be sure its twilio communicating with us, someone could just be calling our application and pretending to be someone with a specific number?Twilio signs requests- it contains a hash of the various paramaters- read the manual, I didn;t at first and spent ages adding hacks and tokens into my apps when they wre not needed
  • #37: How do you debug phone apps?Powerful debugging toolLogs each time an error occursGives full output of what twilio sent and what it received.
  • #38: Sandbox..
  • #41: Field serviceFly around the world to install a GPRS unit- dont have internet access themselves to check the data comes throughSo they phone up and askDriver alertsRoute deviationRange issues as a result
  • #42: I’m not going to answer this one; hopefuly by now, you already have a few ideas..
  • #43: Let’s build some stuff:Phone number verificationLead trackingConference talk feedback
  • #44: Requirement: You need to verify the validity of a users phone number.Ask the user for their number and tell them an access codeCall the numberAsk for the access codeCheck the access codeVerify the number
  • #46: Create an unverified user object, this has a verified status property of falseUse data posted in a form to populateGenerate a random codeSave the userGet the ID
  • #47: Initialise the twilio client, with our secret API detailsCreate a callSet out outoing number,The incoming number,And the URL which will generate the XML for the call
  • #48: We need to ask for a response:Create the twilm objectRequest 4 digits and post them back to our appAsk the caller to provide the code and output the XML
  • #49: When processing the callback, get the digits they pressedVerify they are correctVerify or reject the verification
  • #50: Got the code wrong? Just ask again
  • #51: All OK? Lets tell them
  • #52: Use a JS heartbeat to look at the databasr to see if the users number is verified, when it is bounce them to a page welcoming them as opposed to the page showing the verification code.
  • #53: Lets walk through itUser signs upCode generatedThey receive the callEnter detailsAccount verified
  • #54: Advertiser signs upA number is automatically assigned to themCalls to that number route to our main tracking applicationCall is loggedCaller is transferred
  • #55: Find a local canadian number, grab the first one and buy it
  • #56: Update it to point to our App
  • #57: We have a new number
  • #58: Twilio posts the number used, so we can have multiple numbers pointing to one app
  • #59: We can even get caller ID data if we want
  • #60: We have the numberLook it up in the databaseFind the actual advertisers / lead owners numberLog the lead conversion (call)Connect the call