How to remove prefix country code from caller number in sip2bri case


There is such scenario: A customer is using a TB200 registered to a SIP Provider and connected to BRI ports of a 3rd party pbx. The SIP Provider always sends the Caller ID number with the International prefix (like +39 Italy), so instead of receiving for example 054XXX5611, it receives from the SIP Provider +39054XXX5611. The SIP Provider can’t make any change in its platform in order to delete +39 prefix. The 3rd party pbx can’t manipulate the Caller ID number.

The problem is about phonebook matching: the customer has set in the pbx several contact names, so if the caller ID arrives as +39xxxxxxxx, the pbx can’t match the Caller ID number with the phonebook contact name, so the customer sees on the phone display +39xxxxxxx instead of the Contact name associated in the pbx.

This article provides custom change on asterisk dialplan of Yeastar ISDN gateway to remove prefix country code from caller number in sip2bri direction.

Applicable Devices

Yeastar TB Gateways

Yeastar TE Gateways


Step 1 Access ssh of gateway followed by this article.

Step 2 Check route name in web interface - Route List, in this demo, it is named 'sip2bri'.

Step 3 Go to file /etc/asterisk/extensions.conf and search for sip2bri, find similar context like below, copy and paste it to /persistent/custom-cfg/extensions_custom.conf, add the new script in red and italic to extensions_custom.conf file, intact dialplan after modified should be similar to screenshot below. 

exten = s,1,Set(CDR(userfield)=Inbound)
exten = s,n,GotoIf(${DB_EXISTS(blacklist/${CALLERID(num)})}?Blacklist-Handle,s,1
exten = s,n,Set(TRUNKDID=${IF($[${ARG2}=s]?${CALLERID(name)}:${ARG2})})
exten = s,n,ExecIf($["${CALLERID(num):0:3}" = "+39"]?Set(CALLERID(num)=${CALLERID(num):3}))
exten = s,n,Goto(Routeout_sip2bri,${ARG2},1)
exten = s,102,Goto(Blacklist-Handle,s,1)

Do not copy above dialplan to your device directly, it's high possible different original dialplan for different devices.

Step 4 Continue to execute below two commands.

root@TB200:~# mypbxconf

root@TB200:~# asterisk -rx 'dialplan reload'

Step 5 Test call.

Have more questions? Submit a request


Please sign in to leave a comment.