简体   繁体   中英

Twilio - strip inbound callerid bits, enable recording and forward call to the original number called

Noob here, I need help with a simple script (php or XML) that strips a portion of the inbound callerid, in Twiml then forwards that call to the original e164 number dialed. Eg. call comes from +16045551212@sip.someprovider.com:5061 - PHP/xml script strips everything off but the e164 number and then twiml that number. So the resulting outbound leg would simply be +16045551212.

Since Twilio supports webhooks, we should be able to take in the number, strip the unwanted bit and return a sanitized number for the outbound leg.

I have recording working and if I place a e164 number in statically, it works fine. I am just having trouble with stripping the unwanted but off the sip uri and telling the system to dial that new number.

I tried using {{From}} but that includes the entire from callerid, including the unwanted sip uri bits.

Twiml webhook I am calling from system...

<Response>
 <Say> This call will be recorded for quality assurance purposes. Please standby.</Say>
 <Dial record="record-from-ringing-dual" callerId="+1xxxxxxxxx">
 <Number>+1xxxxxxxx
 </Number>
</Dial> 
</Response>

I would be grateful for any help here!

Have you looked at the {#e164} function of TwiML Bins?

How to use templates with TwiML Bins

Execute Built-in Functions The last feature to share is access to built-in functions. The first such built-in function to ship makes it easy to pull a phone number out of parameters and reformat as E.164. This is very helpful when bridging SIP endpoints such as a Polycom phone with the PSTN world.

For example, let's say a Voice call comes in to a SIP Interface with a To value of sip:+15125551212@mydomain.sip.us1.twilio.com. Since the e.164 phone number is embedded in the SIP endpoint's address, you can use the new built-in e164 function to pull out this phone number and craft the proper TwiML to forward the call:

<Response>
  <Dial>{{#e164}}{{To}}{{/e164}}</Dial>
</Response>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM