Twilio Trunk Manipulation for International from US

Hello,

I am new to FreePBX. I have tried searching the forums but cannot seem to get the right settings set on my system.

I have a trunk with Twilio for outbound service. Dialing NANP numbers right now works fine. Dialing international numbers is giving the following message in the logs following by “The number you have dialed is not in service.”

-- Executing [1@macro-dialout-trunk:1] Goto("SIP/17976-00000052", "s-INVALIDNMBR,1") in new stack

First, I am in US so the format I am dialing is 011+country code+area code+number. For this test, I am using the Hilton London number of +442074938000. It is being dialed on my handset as the following 011442074938000.
Second, dialing this number on a standard POTS line dials fine using the above number as I wrote it.
Third, My Outbound Routes are as follows:

prepend,prefix,“match pattern”,callerid
,011.,
,1800NXXXXXX,
,1833NXXXXXX,
,1844NXXXXXX,
,1855NXXXXXX,
,1866NXXXXXX,
,1877NXXXXXX,
,1888NXXXXXX,
,1NXXNXXXXXX,
1,NXXNXXXXXX,

Lastly, Twilio requires ALL dialed calls to be in E.164 format. This was fairly easy to accomplish by adding a + in the Outbound Dial Prefix field under Dialed Number Manipulation Field.
This is where I think I have a problem. No matter what I enter for trying to rewrite the 011 rule, it always sends the call to Twilio as follows:

== Spawn extension (from-trunk-sip-TwilioTrunk, 011442074938000, 1) exited non-zero on ‘SIP/TwilioTrunk-0000005b’
– SIP/TwilioTrunk-0000005b Internal Gosub(func-apply-sipheaders,s,1) complete GOSUB_RETVAL=
– Called SIP/TwilioTrunk/+011442074938000

I have confirmed this by going thru the “Debugger” and the logs in my account. I have added a rule for 011. putting 011 in the prefix, I have tried 011X., 011N., 011[0-9]. all of which don’t drop the 011. Is there something special about the 011 that I haven’t figured out yet? I can’t seem to figure out why some rules appear to work and others don’t.
If I add a rule to match “.” and prepend + and remove + from the Outbound Dial Prefix, it works. But if I add a rule that matches 1NXXNXXXX and prepends + it doesn’t. If I have something set in Outbound Route and I not allowed to modify it under the Trunk?

I’ve beat my ahead against the wall and was hoping someone could offer some assistance.


Edit: I uploaded a screenshot of my Dial Manipulation Rules. The ones for 7 and 10 digit work, the one for 011 does not.

Edit 2: Upload showing log from Twilio showing the number they received has 011 and is not formatted correctly. i (dot) imgur (dot) com/7oimK04.png (you’ll have to copy/paste)

The 011 rule in the picture you posted is a Prefix which is being removed upon passing this route.
You need to set 011. In the pattern section, leave prefix empty.

I’m puzzled why it’s not working for you.

This pattern doesn’t make sense to me; perhaps you meant to match 1NXXNXXXXXX but that would not affect your international call attempts.

On a test system, I created an Outbound Route with:

and a trunk with:

and it worked as expected (confirmed using ‘pjsip set logger on’ that the outbound INVITE started with + followed by the country code and number).

I suspect an error in testing (failed to Submit, failed to Apply Config, looked at old log, conflicting route or trunk, etc.)
Please post a screenshot of the Outbound Route (if you have multiple, put the one being discussed at the top) and Trunk dial patterns. Confirm that the Outbound Route points to the proper trunk. Turn on pjsip logging and make an attempted UK call. Make a copy of all the Asterisk log entries for the attempt. After masking personal info, paste it at pastebin.freepbx.org and post the link here.

Thanks Stewart,

Sorry if I didn’t make myself clear. What I was meaning to say was if I took the + out of the Outbound Dial Prefix and had a rule to match only 1NXXNXXXX with a prepend of + it wouldn’t work but if I just had it match only “.” it would.

It doesn’t matter anymore since, even though I restarted asterisk from the CLI many times, a good ol’ fashion “init 6” of the system made it start working correctly. I do not know why this was. I was applying the config after each change. I could see in the console of “asterisk -rvvv” that it was in fact reloading after each “Apply Config”. So maybe I hit some bug, not sure. But at any rate, it is working fine now. I have even added other dial manipulation rules that weren’t working before and they are being manipulated as defined.


Note: There is another Outbound Route that handles 911 calling to force recording. It is not shown in the image above. I have 7 and 10 digit dialing manipulated on both the Outbound Route and Trunk to double check that if for any reason a call makes it to the trunk without being changed (ie, if we ever add more Outbound Routes in the future for certain calls) that they are modified correctly.

TLDR; I rebooted the physical server and now everything is working fine.

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