Caller Name / dial plan issue

We have a trunk provider that (using SIP) passes the DID dialed as: ###########;phone-context=national (Using from-trunk context).

I couldn’t find a context that would correctly identify the DID passes without the other garbage so I created a new context:

[from-trunk-custom]
exten => _X.,1,Set(IncomingNumber=${CUT(EXTEN,;,1)})
exten => _X.,1,Set(__FROM_DID=${CUT(EXTEN,;,1)})
exten => _X.,n,Set(CALLERID(name)=${CUT(SIP_HEADER(From),",2)})
exten => _X.,n,Goto(from-pstn,${CUT(EXTEN,;,1)},1)

This context works fine with this provider except the Caller Id Name always get’s set to the Caller Id Number even tho it’s coming in on the from of the sip invite:

<— SIP read from UDP:10.185.17.141:5060 —>
INVITE sip:##########;phone-context=national@10.185.17.142;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.185.17.141:5060;branch=z9hG4bKm9sae5jnanbcdm2jqej3p97s91
From: “Jane Smith”;tag=SDno1a401-36626

My above context set’s the CALLERID(name) correctly but it get’s overridden by the from-pstn context.

How can I fix this and I have to be careful because we have other trunks using the from-trunk correctly, caller Id and all so I need to have both cases working.

Asterisk 1.8

Thanks.

The From header in your example is syntactically invalid, so it is not possible to identify a caller ID in it.

name-addr = [ display-name ] LAQUOT addr-spec RAQUOT
addr-spec = SIP-URI / SIPS-URI / absoluteURI
From = ( “From” / “f” ) HCOLON from-spec
from-spec = ( name-addr / addr-spec )
*( SEMI from-param )
from-param = tag-param / generic-param
tag-param = “tag” EQUAL token

There is no “<” and there is no scheme needed to define an absolute URI.

Also, there is no from-pstn context defined by Asterisk. You need to direct this question to the person or organisation that wrote the dialplan that defined that context, possibly www.freepbx.org.