Change incoming CID to E164


I don’t quite understand how to change incoming national CIDs to E164 format. Our PBX has trunks from multiple countries so incoming calls should be displayed in E164 instead of national format so the person who picks up the call can know what country the call originates from. I have found a solution which works but I would like to narrow it down a bit more.
On trunk “Factory” we have to first get the called party info from the To field, this is done with a copy of the from-pstn-toheader rule (factory1) which then forwards this flow to another context, factory2 (I was unable to condense the rules into one context).

exten =>  _.,1,NoOp(Attempting to extract DID from SIP To header)
exten =>  _.,n,gotoif($["${CHANNEL(channeltype)}"="SIP"]?SIP)
exten =>  _.,n,gotoif($["${CHANNEL(channeltype)}"="PJSIP"]?PJSIP)
exten =>  _.,n,NoOp(Unable to determine SIP channel type)
exten =>  _.,n,goto(factory2,${EXTEN},1))
exten =>  _.,n(SIP),Goto(factory2,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)
exten =>  _.,n(PJSIP),Goto(factory2,${CUT(CUT(PJSIP_HEADER(read,To),@,1),:,2)},1)
exten => _.,1,ExecIf($[ "${CALLERID(name):0:1}" = "0" ]?Set(CALLERID(name)=+41${CALLERID(name):1}))
exten => _.,n,ExecIf($[ "${CALLERID(num):0:1}" = "0" ]?Set(CALLERID(num)=+41${CALLERID(num):1}))
exten => _.,n,goto(from-pstn,${EXTEN},1)

The purpose of the rule would be to change any number that starts with 0 and is 10 digits long to +41 and the last 9 digits of the calling number (0ZXXXXXXXX -> +41ZXXXXXXXX), as I understand it this rule (factory2) changes ANY number that starts with 0 to +41 so a call from Germany that could be signalled from the provider as 0049XXXX would be changed to +41049XXXX.

Any help would be appreciated.

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