Reverse DID & CallerId on PRI for Asterisk as middleman

I have my Asterisk in between a Merlin Legend and the outside world. The phone company PRI is coming into Asterisk and another PRI from my Merlin Legend is attached to Asterisk (Asterisk is between the phone company and the Legend).

Phone Co. <–PRI–> [Asterisk] <–PRI–> Merlin Legend Phones

This allows us to continue to use our old deskphones, but take advantage of many Asterisk features.

I wrote a couple “Custom Destinations” to transfer calls between the PRIs. It works fine, BUT for outgoing calls from the Legend:

  1. The DID is now the number I’m calling
  2. The CallerId is seen as the DID.
  3. Additionally the CDR is incorrect, showing my main number as the number dialed

In Zapata.conf I put in
signalling=pri_net

Question: Is there a way to tell a PRI port to reverse or swap the DID & Caller ID?

You can change the Caller ID before you route out of the Asterisk box. In the context for calls coming from the Legend PBX try setting the CALLERID.

[from-legend]
exten => _X.,1,Set(CALLERID(name)="MyCompany")
exten => _X.,n,Set(CALLERID(num)=18005551234)
exten => _X.,n,Dial(DAHDI/g11/${EXTEN})