Twilio + Call Forwarding / SIP REFER

Hi all,

I use Twilio for SIP trunking and I’m having an issue with call forwarding. If a user is forwarding their calls, Twilio rejects it because the caller ID is not verified. From what I’ve read, Twilio expects to receive forwarded calls via SIP REFER, but I’m not quite sure how to change the FreePBX behavior to accommodate that.

There are several other threads on the forums with people experiencing the same issue, but no one has posted their solution and I’m hoping to see if anyone can help me!


1 Like

Asterisk can send REFER but there is nothing in FreePBX that uses it; you would have to write some custom dialplan. See . REFER asks the provider to take over the call and it is disconnected from Asterisk. IMO this is a bad idea in most cases.
You would be unable to record the call or permit further transfers. The CDRs wouldn’t show the call duration or even whether it was answered. It wouldn’t work if the call originated with another provider.

An easy quick workaround is to use Follow Me instead of forwarding (this is usually better anyhow) and set Change External CID Configuration to Outside Calls Fixed CID Value, with Fixed CID Value set to your main company number (or other number of yours). Of course, the forwarded call won’t show the original caller’s number.

If you must use forwarding, set up a trunk with a forced Trunk CID, an Outbound Route with a prefix that specifies the new trunk, and use that prefix with your forward-to destinations.

If you want to pass the original caller’s number, get a secondary trunking provider that allows sending numbers that are not yours. Telnyx and Flowroute are IMO comparable to Twilio in reliability and support and may have the additional advantage of being a carrier in your city. VoIPInnovations (a Sangoma company) and Vitelity are also excellent but have minimum monthly commitments, so would likely be suitable only if you were switching away from Twilio. AnveoDirect and Voxbeam are IMO a step down but may make good secondary providers if you do much international calling.

1 Like

Thanks for your reply! I was really hoping for better news…for now, I’m just going to set the CallerID behavior to transmit the trunk CID, but I’m still holding out for a solution that allows me to easily transmit the incoming call’s CID.

Get an account with Telnyx or Flowroute. Both give you a small credit at signup so you can test without making a payment or providing any financial info. Both trunks are very easy to set up (I’ll provide details if needed). It should take no more than 15 minutes to do a test.

1 Like

Thanks! I’m thinking about trying that, but how do you only place forwarded calls over a different trunk?

Simplest is to create an Outbound Route with a prefix that uses the new trunk e.g. you dial 02125551212 and 12125551212 gets sent to the new trunk. For this:
prepend: 1, prefix: 0, match pattern NXXNXXXXXX
Then set up your forward to use an initial 0

Or, set up an Outbound Route for the new trunk that matches only forwarded calls, e.g. CallerID field is
(Add an initial + if that’s how your incoming caller ID is displayed.)
This route would go in front of your regular routes (but after your emergency routes).

In either case, you need to be sure that the caller ID from the incoming trunk (after any processing by your context or Set CallerID) is in the format required by the outbound trunk (Telnyx and Flowroute will accept 12125551212 or +12125551212 but not 2125551212).

Note: when I first tested this I also had Follow Me enabled, which conflicts with this forwarding setup. I did not test Follow Me in lieu of forwarding.

i also face same issue and now i write complete custom dialplan for call transfer like call forward in freepbx.
as per my dialplan
PBX internal user just use this dialplan like call forward.
PBX users dial *12 (new custom feature code) ---- IVR will ask for input call transfer number ----- and hangup

now when any incoming call hit on pbx it will transfer to new destination as defined.

if required i can share complete code here


This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.