Search code examples
phplaravel-4twiliotwilio-phptwilio-click-to-call

Trying to figure out a how call works in twilio


As subject says I am reading api docs for twilio but even after brainstorming for 2 hours I am still unable to figure out exactly how can I receive a call from twilio on my web application and answer the call with my own voice like we do in a real phone.

I know how to respond a call when someone call your twilio number but that's only text to speech conversion like their "Hello Monkey" example application but nothing so far about answering a call using their API.

Can anyone please explain how can we do that? Not everything, just main concept and few references if possible

I am using Laravel so would be good if it's in php


Solution

  • Twilio evangelist here.

    I would suggest working through the Twilio Client for JavaScript Quickstart. This will walk you through both the server and client side code needed to build a phone in your browser, showing you how to both make outbound calls from the browser to a PSTN phone as well as receive incoming PSTN calls in the browser.

    The magic that you are looking for in either of those cases is the <Dial> verb. When an incoming PSTN call comes into Twilio, you can use the Dial verb to tell Twilio to dial and bridge that call with a Client instance:

    <Dial>
        <Client>jenny</Client>
    </Dial>
    

    When and instance of client make an outbound call and wants to connect to a PSTN phone number you again us the Dial verb:

    <Dial>
        <Number>+15555555555</Number>
    </Dial>
    

    The quickstart shows in more detail how this works.

    Hope that helps.