Manipulating Callerid per Outbound Trunk

Hi,
I´ve got a little problem with my 2 outbound trunks. I´ve got 2 providers connected to this trunks. The first one need the callerid set like “78112345” and the second like “4978112345” to show up the numbers correctly to the called people. Setting one callerid fixed per trunk issnt possible. i need different callerids for my whole extensions so it has to be passed to the trunk from the extensions.

I know there isn´t a gui option. What i need is a hint how i can set this at a custom context. May someone has done this bevorem and can give me some information how i could build this?

Thanks alot.

Mysterious

I don’t know if anyone has done this but if you’re going to take a whack at it, I suggest you look at How to send calls to different trunks at different times of day for an example of how to intercept a call on its way to a trunk to execute some custom code, and at How to change incoming CallerID for an example of Caller ID manipulation. You may or may not be able to put these two concepts together to do what you need to do. Seems you’d really only need to intercept calls headed for the second trunk and simply prepend the “49” to the existing Caller ID, so you’d think it should not take more than one custom trunk, and three or four lines of custom dial plan in extensions_custom.conf .

I wish I’d had seen this thread before posting mine. Essentially we want to detect the trunk and handle the situation conditionally. If I find something I’ll follow-up here as well.

  1. IF the “OUTBOUND Caller ID” field on each of the two TRUNKS page is BLANK, and 2) IF the “OUTBOUND CID” field on each of the specific EXTENSIONS page is SET <78112345>, then you should have what you need (if I understand the question correctly).

Yes/no?

Then the question becomes how to steer the calls to the correct outbound trunk. If you can train one group of users to dial “9” for an outside line, and the other group “8” (or whatever values you’d like), then you just set that up in the OUTBOUND ROUTE page.

Alternatively, something along the line of,

/etc/asterisk/extensions_custom.conf

[macro-dialout-trunk-predial-hook]
;
exten => s,1,NoOp()
exten => s,n,Set(DIAL_TRUNK=${IF($[${CALLERID(num):0:2}" = "49"]?<trunk1-string>:<trunk2-String>) 
exten => s,n(Done),MacroExit
;

/S

I forgot about this page, which might also be helpful:

How to execute a custom dial plan fragment before sending a call to a trunk (for playing an announcement, etc.)

The comment by 8f27e956 is very helpful. I updated my thread with how I was able to resolve this.

Don’t know if it has been fixed in never version, but 2.6.2.3 still has “bug” with overriding CallerID by TrunkID.

Quick fix is - change line order in extension_additional.conf:

/etc/asterisk$ diff extensions_additional.conf extensions_additional.conf.2013-08-28
3545,3546c3545,3546
< exten => s,n(trunkcid),ExecIf($[“${USEROUTCID:1:2}” != “”],Set,CALLERID(all)=${USEROUTCID})
< exten => s,n(usercid),ExecIf($[“${TRUNKOUTCID:1:2}” != “”],Set,CALLERID(all)=${TRUNKOUTCID})

exten => s,n(trunkcid),ExecIf($[“${TRUNKOUTCID:1:2}” != “”],Set,CALLERID(all)=${TRUNKOUTCID})
exten => s,n(usercid),ExecIf($[“${USEROUTCID:1:2}” != “”],Set,CALLERID(all)=${USEROUTCID})
3836a3837,3838

Please don’t post code fragments. Submit a ticket please.

Version 2.6 has been end of life for 2 years I think.