Some VOIP providers send the DID only in the to field of the SIP Invite message.
With Chan_sip trunks we used the context [from-pstn-toheader] contained in extensions.conf to extract the DID and pass it to [from-pstn].
With PJSIP the syntax has changed, therefore I have overcome this by adding a new context [from-pstn-pjsip-toheader] in extensions_custom.conf as follows:
[from-pstn-pjsip-toheader]
exten => _.,1,Goto(from-pstn,${CUT(CUT(PJSIP_HEADER(read,To),@,1),:,2)},1)
Please note there should be an underscore between PJSIP and HEADER (PJSIP_HEADER). For some reason it is being missed out when I post.[Fixed by mod]
I use this new context when setting up a PJSIP trunk. Perhaps it would be a good idea to include this context in extensions.conf of new builds?