Search code examples
twiliosip

Twilio, pstn to sip, using a web handler to gain account id etc?


I'm trying to use Twilio to forward a caller to our sip communications infrastructure.

So a caller would dial the number setup in Twilio, a web hook would then produce Twiml to challenge and welcome the user.

Then I guess there would need to be something which would access the sip feature in Twilio to forward on to our sip communications infrastructure.

I've looked at the 'Get Started with Elastic SIP Trunking' help on the Twilo site, but the guide focuses on Twilio used in a 'Termination' stage.

Just looking for some guidance on how we would tie this all together?


Solution

  • Twilio developer evangelist here.

    If you want to direct an incoming call to a Twilio number onto a SIP address then you need the TwiML element <Sip>. Nested within a <Dial> it lets you direct calls onto your SIP infrastructure.

    So, in response to the incoming webhook, you need to return the TwiML that will Dial onto your SIP address like this:

    <Response>
      <Dial>
        <Sip>
          sip:jack@example.com
        </Sip>
      </Dial>
    </Response>
    

    You can add more TwiML before this, to welcome or challenge the user if that's what you need.

    Sorry you got caught up in Elastic SIP trunking.