Outbound CID based on dialing prefix w/o editing extensions_custom?

tzalmaves

New Member
Joined
Jun 12, 2009
Messages
25
Reaction score
0
Hello all,

I'm migrating from PIAF on VMWARE to a dedicated machine, so I thought I'd revisit this:

Currently, I set my outbound caller ID based on what prefix I dial. Here's a bit of what I have in extensions_custom:

exten => _25NXXNXXXXXX,1,Set(CALLERID(all)="Caller ID One" <5555551212>)
exten => _25NXXNXXXXXX,n,Macro(dialout-trunk,5,1${EXTEN:2},,)
exten => _25NXXNXXXXXX,n,Macro(dialout-trunk,7,1${EXTEN:2},,)
exten => _25NXXNXXXXXX,n,Macro(dialout-trunk,1,${EXTEN:2},,)
exten => _25NXXNXXXXXX,n,Macro(outisbusy,)

exten => _26NXXNXXXXXX,1,Set(CALLERID(all)="Caller ID Two" <6666662323>)
exten => _26NXXNXXXXXX,n,Macro(dialout-trunk,5,1${EXTEN:2},,)
exten => _26NXXNXXXXXX,n,Macro(dialout-trunk,7,1${EXTEN:2},,)
exten => _26NXXNXXXXXX,n,Macro(dialout-trunk,1,${EXTEN:2},,)
exten => _26NXXNXXXXXX,n,Macro(outisbusy,)


...I'm wondering if there's a way to do this in the FreePBX shell, without resorting to adding lines to extensions_custom. If only the "outbound routes" page had an entry for setting caller ID!

I'm running the Orgasmatron for Everex.

Thanks for any help you can provide,

-TM
 

Boolah

Guru
Joined
Nov 16, 2007
Messages
331
Reaction score
20
I suppose you could create a separate trunk for each CID you want to use. Then tie the prefix you dial to only use that specific trunk.

For example, you create Trunk 1 with CID 1 and Trunk 2 with CID 2. Then create two Outbound Routes. For your Dial Patters under your first Outbound Route, add the following to use CID 1:

25|NXXNXXXXXX

... to use Trunk 2 add ...

26|NXXNXXXXXX

Restrict the first route to only use Trunk 1 and the second route to only use Trunk 2. It's messy, but it should work.
 

tzalmaves

New Member
Joined
Jun 12, 2009
Messages
25
Reaction score
0
I suppose you could create a separate trunk for each CID you want to use. Then tie the prefix you dial to only use that specific trunk.

For example, you create Trunk 1 with CID 1 and Trunk 2 with CID 2. Then create two Outbound Routes. For your Dial Patters under your first Outbound Route, add the following to use CID 1:

25|NXXNXXXXXX

... to use Trunk 2 add ...

26|NXXNXXXXXX

Restrict the first route to only use Trunk 1 and the second route to only use Trunk 2. It's messy, but it should work.

Hi Boolah,

Yes, that has occured to me, but in reality I have five prefixes. I'd rather use extensions_custom than have five phone bills to pay each month. :)

-TM
 

Boolah

Guru
Joined
Nov 16, 2007
Messages
331
Reaction score
20
I'd rather use extensions_custom than have five phone bills to pay each month.

You shouldn't need to setup different accounts with your VoIP providers. All trunks should be under the same account. Most providers do not require you to register to make calls, only to receive calls. So you can register on your inbound (User) trunk (if you even have any DIDs from your provider) and just setup Peer settings for as many trunks as required.
 

tzalmaves

New Member
Joined
Jun 12, 2009
Messages
25
Reaction score
0
Last edited by a moderator:

tzalmaves

New Member
Joined
Jun 12, 2009
Messages
25
Reaction score
0
You shouldn't need to setup different accounts with your VoIP providers. All trunks should be under the same account. Most providers do not require you to register to make calls, only to receive calls. So you can register on your inbound (User) trunk (if you even have any DIDs from your provider) and just setup Peer settings for as many trunks as required.

So you're saying I can fill in the "outgoing settings" section, leave the "incoming settings" section blank, and leave the "registration" portion blank as well?

-TM
 

Boolah

Guru
Joined
Nov 16, 2007
Messages
331
Reaction score
20
Yes - that should be all you need to do. BTW - which provider are you using?
 

Boolah

Guru
Joined
Nov 16, 2007
Messages
331
Reaction score
20
I know it will work with les.net I have no experience with Voicepulse, but from what I've read about them, you should be able to do the same with them.
 

tzalmaves

New Member
Joined
Jun 12, 2009
Messages
25
Reaction score
0
I guess I'll keep doing it the old fashioned way. Thanks for the advice!

-TM
 

ronw

Guru
Joined
Mar 30, 2008
Messages
165
Reaction score
0
I posted this method several months ago.

If you are not and do not plan to use route passwords, then you can use the following procedure to assign callerid to outbound routes:

First, put the following in extensions_override_freepbx.conf

[sub-pincheck]
exten => s,1,Set(CALLERID(all)=${ARG3})
exten => s,n,Return()
; end of [sub-pincheck]

On each Outbound Route in FreePBX that you want a specific callerid number, enter the number in the Route Password box and check the Intra Company Route box. If you do not check Intra Company Route, FreePBX will use the callerid set in the trunk or extension.

ronw
 

tzalmaves

New Member
Joined
Jun 12, 2009
Messages
25
Reaction score
0
I posted this method several months ago.

If you are not and do not plan to use route passwords, then you can use the following procedure to assign callerid to outbound routes:

First, put the following in extensions_override_freepbx.conf

[sub-pincheck]
exten => s,1,Set(CALLERID(all)=${ARG3})
exten => s,n,Return()
; end of [sub-pincheck]

On each Outbound Route in FreePBX that you want a specific callerid number, enter the number in the Route Password box and check the Intra Company Route box. If you do not check Intra Company Route, FreePBX will use the callerid set in the trunk or extension.

ronw

Wow, that's slick! There's so much I have to learn....

It doesn't seem to work - I still get the authentication request, and the callerID isn't being set. It looks like the authentication is handled in macro-dialout-trunk - do I need to do something more to have it skip the authentication request?

-TM
 

ronw

Guru
Joined
Mar 30, 2008
Messages
165
Reaction score
0
This method works with Piaf. I am not sure with Trixbox. The sub-pincheck routine is called from macro-dialout-trunk. The modified sub-pincheck routine in extensions_override_freepbx.conf will override the sub-pincheck in extensions_additional.conf.

There should be an include in extensions.conf for the override to be active:
#include extensions_override_freepbx.conf

Also, restart asterisk.
 

tzalmaves

New Member
Joined
Jun 12, 2009
Messages
25
Reaction score
0
This method works with Piaf. I am not sure with Trixbox. The sub-pincheck routine is called from macro-dialout-trunk. The modified sub-pincheck routine in extensions_override_freepbx.conf will override the sub-pincheck in extensions_additional.conf.

There should be an include in extensions.conf for the override to be active:
#include extensions_override_freepbx.conf

Also, restart asterisk.

Hi Ron,

Yes, I am using the PIAF "Orgasmitron" install for Everex.

Line 31 on extensions.conf shows:
#include extensions_override_freepbx.conf

Yes, I executed "amportal restart" after making the edit.

My macro-dialout-trunk does not contain sub-pincheck (see below) - do I need an update?

-TM

===================
[macro-dialout-trunk]
include => macro-dialout-trunk-custom
exten => s,1,Set(DIAL_TRUNK=${ARG1})
exten => s,n,ExecIf($[$["${ARG3}" != ""] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]],Authenticate,${ARG3})
exten => s,n,GotoIf($["x${OUTDISABLE_${DIAL_TRUNK}}" = "xon"]?disabletrunk,1)
exten => s,n,Set(DIAL_NUMBER=${ARG2})
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${DIAL_OPTIONS})
exten => s,n,Set(OUTBOUND_GROUP=OUT_${DIAL_TRUNK})
exten => s,n,GotoIf($["${OUTMAXCHANS_${DIAL_TRUNK}}foo" = "foo"]?nomax)
exten => s,n,GotoIf($[ ${GROUP_COUNT(OUT_${DIAL_TRUNK})} >= ${OUTMAXCHANS_${DIAL_TRUNK}} ]?chanfull)
exten => s,n(nomax),GotoIf($["${INTRACOMPANYROUTE}" = "YES"]?skipoutcid)
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${TRUNK_OPTIONS})
exten => s,n,Macro(outbound-callerid,${DIAL_TRUNK})
exten => s,n(skipoutcid),ExecIf($["${PREFIX_TRUNK_${DIAL_TRUNK}}" != ""],AGI,fixlocalprefix)
exten => s,n,Set(OUTNUM=${OUTPREFIX_${DIAL_TRUNK}}${DIAL_NUMBER})
exten => s,n,Set(custom=${CUT(OUT_${DIAL_TRUNK},:,1)})
exten => s,n,ExecIf($[$["${MOHCLASS}" != "default"] & $["${MOHCLASS}" != ""]],Set,DIAL_TRUNK_OPTIONS=M(setmusic^${MOHCLASS})${DIAL_TRUNK_OPTIONS})
exten => s,n(gocall),Macro(dialout-trunk-predial-hook,)
exten => s,n,GotoIf($["${PREDIAL_HOOK_RET}" = "BYPASS"]?bypass,1)
exten => s,n,GotoIf($["${custom}" = "AMP"]?customtrunk)
exten => s,n,Dial(${OUT_${DIAL_TRUNK}}/${OUTNUM},300,${DIAL_TRUNK_OPTIONS})
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n(customtrunk),Set(pre_num=${CUT(OUT_${DIAL_TRUNK},$,1)})
exten => s,n,Set(the_num=${CUT(OUT_${DIAL_TRUNK},$,2)})
exten => s,n,Set(post_num=${CUT(OUT_${DIAL_TRUNK},$,3)})
exten => s,n,GotoIf($["${the_num}" = "OUTNUM"]?outnum:skipoutnum)
exten => s,n(outnum),Set(the_num=${OUTNUM})
exten => s,n(skipoutnum),Dial(${pre_num:4}${the_num}${post_num},300,${DIAL_TRUNK_OPTIONS})
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n(chanfull),Noop(max channels used up)
exten => s-BUSY,1,Noop(Dial failed due to trunk reporting BUSY - giving up)
exten => s-BUSY,n,Playtones(busy)
exten => s-BUSY,n,Busy(20)
exten => s-NOANSWER,1,Noop(Dial failed due to trunk reporting NOANSWER - giving up)
exten => s-NOANSWER,n,Playtones(congestion)
exten => s-NOANSWER,n,Congestion(20)
exten => s-CANCEL,1,Noop(Dial failed due to trunk reporting CANCEL - giving up)
exten => s-CANCEL,n,Playtones(congestion)
exten => s-CANCEL,n,Congestion(20)
exten => s-CHANUNAVAIL,1,GotoIf($["x${OUTFAIL_${ARG1}}" = "x"]?noreport)
exten => s-CHANUNAVAIL,n,AGI(${OUTFAIL_${ARG1}})
exten => s-CHANUNAVAIL,n(noreport),Noop(TRUNK Dial failed due to ${DIALSTATUS} (hangupcause: ${HANGUPCAUSE}) - failing through to other trunks)
exten => _s-.,1,GotoIf($["x${OUTFAIL_${ARG1}}" = "x"]?noreport)
exten => _s-.,n,AGI(${OUTFAIL_${ARG1}})
exten => _s-.,n(noreport),Noop(TRUNK Dial failed due to ${DIALSTATUS} - failing through to other trunks)
exten => disabletrunk,1,Noop(TRUNK: ${OUT_${DIAL_TRUNK}} DISABLED - falling through to next trunk)
exten => bypass,1,Noop(TRUNK: ${OUT_${DIAL_TRUNK}} BYPASSING because dialout-trunk-predial-hook)
exten => h,1,Macro(hangupcall,)

; end of [macro-dialout-trunk]

===================
 

ronw

Guru
Joined
Mar 30, 2008
Messages
165
Reaction score
0
I have FreePBX version 2.5.1.5 and my macro-dialout-trunk looks like:

=========
[macro-dialout-trunk]
include => macro-dialout-trunk-custom
exten => s,1,Set(DIAL_TRUNK=${ARG1})
exten => s,n,GosubIf($[$["${ARG3}" != ""] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]]?sub-pincheck,s,1)
exten => s,n,GotoIf($["x${OUTDISABLE_${DIAL_TRUNK}}" = "xon"]?disabletrunk,1)
exten => s,n,Set(DIAL_NUMBER=${ARG2})
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${DIAL_OPTIONS})
exten => s,n,Set(OUTBOUND_GROUP=OUT_${DIAL_TRUNK})
exten => s,n,GotoIf($["${OUTMAXCHANS_${DIAL_TRUNK}}foo" = "foo"]?nomax)
exten => s,n,GotoIf($[ ${GROUP_COUNT(OUT_${DIAL_TRUNK})} >= ${OUTMAXCHANS_${DIAL_TRUNK}} ]?chanfull)
exten => s,n(nomax),GotoIf($["${INTRACOMPANYROUTE}" = "YES"]?skipoutcid)
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${TRUNK_OPTIONS})
exten => s,n,Macro(outbound-callerid,${DIAL_TRUNK})
exten => s,n(skipoutcid),ExecIf($["${PREFIX_TRUNK_${DIAL_TRUNK}}" != ""],AGI,fixlocalprefix)
exten => s,n,Set(OUTNUM=${OUTPREFIX_${DIAL_TRUNK}}${DIAL_NUMBER})
exten => s,n,Set(custom=${CUT(OUT_${DIAL_TRUNK},:,1)})
exten => s,n,ExecIf($[$["${MOHCLASS}" != "default"] & $["${MOHCLASS}" != ""]],Set,DIAL_TRUNK_OPTIONS=M(setmusic^${MOHCLASS})${DIAL_TRUNK_OPTIONS})
exten => s,n(gocall),Macro(dialout-trunk-predial-hook,)
exten => s,n,GotoIf($["${PREDIAL_HOOK_RET}" = "BYPASS"]?bypass,1)
exten => s,n,GotoIf($["${custom}" = "AMP"]?customtrunk)
exten => s,n,Dial(${OUT_${DIAL_TRUNK}}/${OUTNUM},300,${DIAL_TRUNK_OPTIONS})
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n(customtrunk),Set(pre_num=${CUT(OUT_${DIAL_TRUNK},$,1)})
exten => s,n,Set(the_num=${CUT(OUT_${DIAL_TRUNK},$,2)})
exten => s,n,Set(post_num=${CUT(OUT_${DIAL_TRUNK},$,3)})
exten => s,n,GotoIf($["${the_num}" = "OUTNUM"]?outnum:skipoutnum)
exten => s,n(outnum),Set(the_num=${OUTNUM})
exten => s,n(skipoutnum),Dial(${pre_num:4}${the_num}${post_num},300,${DIAL_TRUNK_OPTIONS})
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n(chanfull),Noop(max channels used up)
exten => s-BUSY,1,Noop(Dial failed due to trunk reporting BUSY - giving up)
exten => s-BUSY,n,Playtones(busy)
exten => s-BUSY,n,Busy(20)
exten => s-NOANSWER,1,Noop(Dial failed due to trunk reporting NOANSWER - giving up)
exten => s-NOANSWER,n,Playtones(congestion)
exten => s-NOANSWER,n,Congestion(20)
exten => s-CANCEL,1,Noop(Dial failed due to trunk reporting CANCEL - giving up)
exten => s-CANCEL,n,Playtones(congestion)
exten => s-CANCEL,n,Congestion(20)
exten => s-CHANUNAVAIL,1,GotoIf($["x${OUTFAIL_${ARG1}}" = "x"]?noreport)
exten => s-CHANUNAVAIL,n,AGI(${OUTFAIL_${ARG1}})
exten => s-CHANUNAVAIL,n(noreport),Noop(TRUNK Dial failed due to ${DIALSTATUS} (hangupcause: ${HANGUPCAUSE}) - failing through to other trunks)
exten => _s-.,1,GotoIf($["x${OUTFAIL_${ARG1}}" = "x"]?noreport)
exten => _s-.,n,AGI(${OUTFAIL_${ARG1}})
exten => _s-.,n(noreport),Noop(TRUNK Dial failed due to ${DIALSTATUS} - failing through to other trunks)
exten => disabletrunk,1,Noop(TRUNK: ${OUT_${DIAL_TRUNK}} DISABLED - falling through to next trunk)
exten => bypass,1,Noop(TRUNK: ${OUT_${DIAL_TRUNK}} BYPASSING because dialout-trunk-predial-hook)
exten => h,1,Macro(hangupcall,)
; end of [macro-dialout-trunk]
 

tzalmaves

New Member
Joined
Jun 12, 2009
Messages
25
Reaction score
0
I have FreePBX version 2.5.1.5
Ah, OK, I have 2.5.0.0. Sounds like I should upgrade. A bit off topic, but we'll get back to the problem at hand, I promise:

I see that I can upgrade FreePBX from the "Module Administration" page in FreePBX. Will that mess up the "PIAF-ness" of my install?

Am I correct in understanding that the "update-source" script in PIAF updates only asterisk, and not FreePBX? Can I update one but not the other, or should I do both?

Anything else I should know?

-TM
 

ronw

Guru
Joined
Mar 30, 2008
Messages
165
Reaction score
0
I see that I can upgrade FreePBX from the "Module Administration" page in FreePBX. Will that mess up the "PIAF-ness" of my install?

No, "PIAF-ness" is not affected by updating FreePBX.

Am I correct in understanding that the "update-source" script in PIAF updates only asterisk, and not FreePBX? Can I update one but not the other, or should I do both?

Yes, you can "update-source" and not FreePBX or update FreePBX and not "update-source", or you can update both, but I have not used update-source since the original install of PIAF 1.4.
 

tzalmaves

New Member
Joined
Jun 12, 2009
Messages
25
Reaction score
0
OK, I've updated FreePBX and now Ron's sub-pincheck modification works! I do have one problem: If I dial out from a local extension, the caller ID is correctly set. However, if I dial the same number via DISA, instead of a local extension, the caller ID specified by the route doesn't get sent. I can see the sub-pincheck set the callerID, but of course the cellrID is earlier set when I come in via DISA. Is it the case that, once callerID has been set, subsequent settings of callerID don't stick? If so, how can I fix this?

I'm happy to post asterisk logs if that helps.

Two "by the way" questions:

1) Is there a way to make DISA not require dialing a "#" at the end of the phone number to initiate the call? On my old asterisk box with FreePBX 2.1.1, I dailed the same as I do from a local extension, with no need for the terminating "#".

2) Are there debugging tools that allow for stepping through asterisk contexts, so one can watch variables changing, etc.? I guess I'm looking for something similar to a software development IDE.

Thanks to everyone for your help!

-TM
 

ronw

Guru
Joined
Mar 30, 2008
Messages
165
Reaction score
0
-TM

What happens if you do not set caller id for DISA? The routine that sets the caller id last should be the callerid sent on the trunk.

Logs would be helpful. I have not used DISA, but will set up for testing.

Ron W.
 

Members online

Forum statistics

Threads
25,850
Messages
168,000
Members
19,269
Latest member
dhonn
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top