Pressing 9 To Select Outside Line

I’d like to configure pressing 9 to select an outside line on my FreePBX setup. I have two PSTN Comcast lines and buttons configured on my phones to select them. I’d like to be able to press 9 to select the next unused line. How do I do that?

For FreePBX Support I recommend their forum at http://community.freepbx.org/

Yup, I’m there. But someone has to have asked this question for bare Asterisk. If I need to manipulate the naked conf files I will. I’ve already setup a couple of dial plans for a gate opener and to play the music on hold list.

How about a dial plan on 9 to select one trunk, if that’s busy, select the next one, if that’s busy play a busy signal then hang up. I’m just not sure how to do that.

Personally I’d set up a Dial Group in Dahdi and just dial out via it, Let DAHDI manage what channels are in use

Then it’s as simple as

exten => _X,1,NoOp()
same => n,Dial(DAHDI/g1/${EXTEN},60,TKW)

Here’s a question. How do you get Asterisk to respond immediately to a keypress? How do you get 9 to fire off a dialplan without needing a #? That is needing 9#?

If using a SIP device then it’s up to the device to determine when a number is complete and send it to Asterisk. This would be configured through its provisioning.

1 Like

Just discovered this. Pressing 9 on my Grandstream phone puts “On-Hook Dialing” on the display and requires a # to take the phone off-hook and send the keypress. I didn’t realize what was going on. I’m now trying to figure out how to provision the phone to behave the way I want. Thanks for the pointer.

I’ve been gently prodded over in the FreePBX forum that this thinking is “old fashioned.” The way to do things in the modern world is to dial your number at the PBX dial tone and let an outbound route select the next available trunk or play a busy signal if all are in use (or whatever you configure.)

I’ve got two trunks. I can get a dial tone on both and can dial out. I have buttons configured on my phone to select these lines.

I’ve configured a single outbound route and some dial plans and it uses both trunks. But when I dial at the PBX dial tone I get a ringing sound but nothing happens. Both trunks remain idle. I have no idea where that call is going.

Without the dialplan and sufficiently detailed logging, we have no idea either!

I was given the command to capture the verbose log elsewhere. Do you happen to know it? I also need to figure out how to display outbound dial patterns from the command line. I may have misspoken if I said dial plans. I was thinking about dial patterns configured in the outbound route.

I’m a bit handicapped working in both in the FreePBX GUI and still learning the Asterisk CLI. I am still learning how to move smoothly between the two.

core set verbose

level 5 is recommended for debugging use. You may also need to invoke the debug log

core set debug 5

and enable it in logger.conf.

I now have a single outbound route. I have actually confirmed it is being used by removing the dial patterns. My dial failed. I put the dial patterns back and my dial went through. But, as I said, it rings and nonthing happens.

[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [9803333@from-internal:8] Macro("SIP/10-00000197", "dialout-trunk,2,9803333,,off") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:1] Set("SIP/10-00000197", "DIAL_TRUNK=2") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:2] GosubIf("SIP/10-00000197", "0?sub-pincheck,s,1()") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:3] GotoIf("SIP/10-00000197", "0?disabletrunk,1") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:4] Set("SIP/10-00000197", "DIAL_NUMBER=9803333") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:5] Set("SIP/10-00000197", "DIAL_TRUNK_OPTIONS=Ttr") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:6] Set("SIP/10-00000197", "OUTBOUND_GROUP=OUT_2") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:7] GotoIf("SIP/10-00000197", "0?nomax") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:8] GotoIf("SIP/10-00000197", "0?chanfull") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:9] GotoIf("SIP/10-00000197", "0?skipoutcid") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:10] Set("SIP/10-00000197", "DIAL_TRUNK_OPTIONS=Tt") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:11] Macro("SIP/10-00000197", "outbound-callerid,2") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:1] ExecIf("SIP/10-00000197", "0?Set(CALLERPRES(name-pres)=)") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:2] ExecIf("SIP/10-00000197", "0?Set(CALLERPRES(num-pres)=)") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:3] ExecIf("SIP/10-00000197", "0?Set(REALCALLERIDNUM=10)") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:4] GotoIf("SIP/10-00000197", "1?normcid") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Goto (macro-outbound-callerid,s,7)
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:7] Set("SIP/10-00000197", "USEROUTCID=") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:8] Set("SIP/10-00000197", "EMERGENCYCID=") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:9] Set("SIP/10-00000197", "TRUNKOUTCID=925-370-1111") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:10] GotoIf("SIP/10-00000197", "1?trunkcid") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Goto (macro-outbound-callerid,s,15)
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:15] ExecIf("SIP/10-00000197", "1?Set(CALLERID(all)=925-370-1111)") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:16] ExecIf("SIP/10-00000197", "0?Set(CALLERID(all)=)") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:17] ExecIf("SIP/10-00000197", "1?Set(CALLERID(all)=925-370-1111)") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:18] ExecIf("SIP/10-00000197", "0?Set(CALLERPRES(name-pres)=prohib_passed_screen)") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:19] ExecIf("SIP/10-00000197", "0?Set(CALLERPRES(num-pres)=prohib_passed_screen)") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:20] Set("SIP/10-00000197", "CDR(outbound_cnum)=9253701111") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-outbound-callerid:21] Set("SIP/10-00000197", "CDR(outbound_cnam)=") in new stack
[2016-04-18 17:48:02] WARNING[19890] func_cdr.c: CDR requires a value (CDR(variable)=value)
)[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:12] GosubIf("SIP/10-00000197", "0?sub-flp-2,s,1()") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:13] Set("SIP/10-00000197", "OUTNUM=9803333") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:14] Set("SIP/10-00000197", "custom=SIP/OfficeLine") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:15] ExecIf("SIP/10-00000197", "1?Set(DIAL_TRUNK_OPTIONS=M(setmusic^customuploaded)Tt)") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:16] ExecIf("SIP/10-00000197", "0?Set(DIAL_TRUNK_OPTIONS=M(setmusic^customuploaded)TtM(confirm))") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:17] Macro("SIP/10-00000197", "dialout-trunk-predial-hook,") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:1] MacroExit("SIP/10-00000197", "") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:18] GotoIf("SIP/10-00000197", "0?bypass,1") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:19] ExecIf("SIP/10-00000197", "1?Set(CONNECTEDLINE(num,i)=9803333)") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:20] ExecIf("SIP/10-00000197", "1?Set(CONNECTEDLINE(name,i)=CID:9253701111)") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:21] ExecIf("SIP/10-00000197", "0?Set(CONNECTEDLINE(name,i)=CID:(Hidden)9253701111") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:22] GotoIf("SIP/10-00000197", "0?customtrunk") in new stack
[2016-04-18 17:48:02] VERBOSE[31862][C-000000b7] pbx.c: Executing [s@macro-dialout-trunk:23] Dial("SIP/10-00000197", "SIP/OfficeLine

So if I read this correct, the trunk is being called. But when I check “core show hints” during the dial, neither of my two trunks show as “in use” but the extension I am using does.

Any ideas?

Please provide your dialplan and sip.conf.

This looks as though it might be FreePBX provided dialplan, in which case you will need to ask on http://community.freepbx.org/ Also, the trunk/extension distinction is a FreePBX thing.

Do you have a call limit set on the “trunk”, as that needs to be set for inuse and busy states to be tracked.

Yeah, this is a FreePBX setup. I was hoping this was a lower level thing that I could get help with here.

For example you ask about call limits. I can set Maximum Channels, which I set to 1 since this is a PSTN line. Tried 2 but still no joy. Inuse and busy are tracked when I take the line off-hook through the configured extension. It’s just this outbound route that won’t take any line off-hook and I don’t know why.

From sip.conf.sample

;call-limit=1                    ; permit only 1 outgoing call and 1 incoming call at a time
                                 ; from the phone to asterisk (deprecated)
                                 ; 1 for the explicit peer, 1 for the explicit user,
                                 ; remember that a friend equals 1 peer and 1 user in
                                 ; memory
                                 ; There is no combined call counter for a "friend"
                                 ; so there's currently no way in sip.conf to limit
                                 ; to one inbound or outbound call per phone. Use
                                 ; the group counters in the dial plan for that.

I’ve no idea what the FreePBX parameter you named maps into. It may well use group counts from the dialplan.

It sure sounds like the same thing.

  1. In your IP Phone’s web interface, in the dial plan set (9|1XXXXXXXXXX,etc,etc)
    See that the 9 is alone.

  2. In the extensions.conf create a Dialplan to when someone dial 9 it executes a DISA.

Result, when you press 9 you IP Phone is going to understand is completed without need to press # then it is going to run the dial plan in extensions.conf and you will hear the DIAL TONE.

Thanks Leunam but I was talked out of this scheme by other users as being “old thinking.” I now understand that dialing into the phone system and using dial plans to let it select the correct outgoing line is ok.

I only have two analog phone lines. I was able to setup a couple of speed dial buttons to dial the trunk associated with each line and get a dial tone on them. This allows my wife to dial out specifically on the “business” line her company is paying for.

I have two outbound routes, one using both lines and putting the business line first. A button dialing the business trunk will use this and will get a dial tone on the business line.

A second outbound route first in line has only the other line with a prefix of 99. If you dial 99 plus the trunk for that line, You’ll get a dial tone there instead. Works great.