You need to create your own context to preprocess calls: Context for scripts (incoming calls) - #16 by lgaetz
It will look like this:
[from-pstn-preprocess]
exten => _.,1,NoOp(Entering user defined context from-pstn-preprocess)
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(from-pstn,${EXTEN},1))
exten => _.,n(SIP),Goto(from-pstn-e164-us,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)
exten => _.,n(PJSIP),Goto(from-pstn-e164-us,${CUT(CUT(PJSIP_HEADER(read,To),@,1),:,2)},1)