How to dial a ring group from within a dial plan


I have a Raspberry Pi Zero with RasPBX with Asterisk 13.13.1 upgraded to 13.15.0 & FreePBX upgraded to

I am not using any SIP provider. The aim initially is to filter incoming PSTN calls via an OBi110.

I’ve defined 2 ring groups: 500 for softphones from 501 etc and 600 for hardphones from 601 (the OBi110 handset 601 is the only hardphone at the moment)

When a PSTN call comes in the Dial Plan has this command:

same => n,Dial(SIP/500&SIP/600)

However this gives errors:
> [2017-06-23 19:20:52] VERBOSE[6557][C-00000009] pbx.c: Executing [[email protected]:2] Dial(“SIP/OBiTrunkSP2-00000007”, “SIP/500&SIP/600”) in new stack
> [2017-06-23 19:20:52] WARNING[6557][C-00000009] chan_sip.c: Purely numeric hostname (500), and not a peer–rejecting!
> [2017-06-23 19:20:52] WARNING[6557][C-00000009] app_dial.c: Unable to create channel of type ‘SIP’ (cause 20 - Subscriber absent)
> [2017-06-23 19:20:52] WARNING[6557][C-00000009] chan_sip.c: Purely numeric hostname (600), and not a peer–rejecting!
> [2017-06-23 19:20:52] WARNING[6557][C-00000009] app_dial.c: Unable to create channel of type ‘SIP’ (cause 20 - Subscriber absent)
> [2017-06-23 19:20:52] VERBOSE[6557][C-00000009] app_dial.c: Everyone is busy/congested at this time (2:0/0/2)
> [2017-06-23 19:20:52] VERBOSE[6557][C-00000009] pbx.c: Executing [[email protected]:3] Hangup(“SIP/OBiTrunkSP2-00000007”, “”) in new stack

I have tested calling the two ring groups from softphones and that works.

I know I can list all the extensions separately or create a macro, but 1) I want to avoid having to remember to change the code when adding an extension; and 2) it just seems a natural /logical thing to ring a ring group.

I’ve spent a couple of hours on the web and surprised that not more people have done this.

BTW, FreePBX is an excellent product :slight_smile:

Thanks for reading.

Dial a ring group with:

Local/[email protected]
1 Like

Thank you Igaetz for a very quick reply. I believe that from-internal is a context which I guess can be empty.

Can I do: Local/[email protected]&Local/[email protected]

If yes, then when defining both my 500 and 600 ring groups in FreePBX I was forced to define a “Destination if no answer” (cannot be left blank). If they are both say go to voice mail and nobody answers then will Asterisk get confused trying to put the call to 2 voice mail boxes? Or if I set one to voice mail and the other say Terminate then will the call go to voice mail or get terminated? Strange there is no “No action” choice in the drop down menu.

Maybe the answer is to define another ring group, say 700 that has all the 500 and 600 phones. But that’s another group to maintain.

Thanks again :slight_smile:

I would probably do it with a third ring group, but you could set the ring time for your two ring groups to something different, so the the failover for the shortest one will always govern.

1 Like

Thanks Igaetz for your continued support. I’ve spent most of the day playing with this without success.

I tried ringing one ring group: 500

In extensions_custom.conf:

same => n,Dial(Local/[email protected])

exten => 800,n,Log(NOTICE, In ring group)
same => n,Dial(SIP/500,30)
same => n,Hangup

and get “Purely numeric hostname (500), and not a peer–rejecting!”

Seems to me that Asterisk dial plan has problems referencing FreePBX Ring Group nos. - or I’ve yet to find the right syntax.

So I changed tack with some success. I set the Dial Plan Trunk context from-house-pstn to include
include => from-pstn

so that if the call is acceptable then the flow continues with FreePBX context. And in FreePBX set the inbound / Set Destination: to 501 (temporary SIP softphone to be replaced with 500 ring group)

This worked for the part of the script for day time accepted callers.

At night time or for number withheld callers, the script transfers direct to voice mail. Virtual Extension 700 in FreePBX is set up for voice mail. The Dial Plan code is:

exten => 0,1,Log(NOTICE, Caller ${CALLERID(all)} to 700 house voice mail)
same => n,Voicemail(700)
; 700 is a virtual extension for House Voice Mail
same => n,Hangup

but this gives an error - I think the error was “No such extension/context 700”

Seems to me that Asterisk has problems referencing FreePBX Virtual Extension nos (as well as Ring Group nos) - or I haven’t got the syntax right, but I read 100s web pages without success…

I changed 700 to a SIP extension (but no physical phone). If I call it from a softphone it goes straight to voice mail (fine) but if I call it from the above script from an inbound call then it says “Unable to create channel of type ‘SIP’ (cause 20 - Subscriber absent)”

I like FreePBX except that it is proving difficult for me to see how in a Dial Plan script within extensions_custom.conf can interface with it. Web examples seem to be plain Asterisk or plain FreePBX.

It’s now 10pm in the UK and I’ve been banned from making any inbound calls and ringing all the phones and I’m banned from disconnecting them in case a real call is made. Will continue tomorrow.


Unless you know EXACTLY what you are doing, use the GUI, if you add “custom stuff”, you will need to “#include” the contexts of which particular endpoint you are trying to contact into that “custom stuff context”, be that “ringgroup” or “night” you did it, you need to sort it, get it?

I would be DELIGHTED to use only the GUI but having spent hours, no days, scanning the web I find a paucity of information in using FreePBX to undertake any call screening.

I’m getting spam and sales calls despite being ex-directory and on the official “do not call list” for over 15 years. Not yet at the level of my elderly neighbours who get 8 to 10 a day and are getting very distressed.

Searching the web for solutions I came across one great guy who freely gave his solution using an OBi110 and a Raspberry Pi with Asterisk and FreePCB. I would gladly buy the guy a beer if he had a donate button.

His solution was a bit simple in that it required callers to identify they are human by pressing a key, so that will not stop determined callers. Further research found another solution that exactly met my needs but it was pure Asterisk. I thought it would be a case simply of copying that script to extensions_custom.conf but that was a misconception on my part.

FreePBX looks a great product. It would be even nicer if the GUI had a facility for defining call filtering rules in the form “if condition then do this else this”. Maybe it’s an add-in that I’ve overlooked.

PS. It’s said that Edison conducted 2,774 experiments before perfecting his light bulb. It’s a good job he didn’t listen to those who said stop experimenting unless he knew what he was doing, or we will be using candles today still :wink:

PS. My basic filtering needs:

If known caller (white list) then 
   if day time or family
       then ring house phones; 
          if no answer 
              go to house voice mail 1 and email me.
       else (night time)
          go to house voice mail 1 and email me.
if no. withheld then
   ask caller to enter pin
   if pin correct 
      then go to known caller
      else ask caller to enter their no.
           if known caller (whitelist)
              then go to known caller
              else go to house voice mail 2 and email me
 if invalid looking caller id or on blacklist
    then terminate call with no. unobtainable message
    else (possible valid caller) 
         ask caller to press 1 if not sales call etc.
         if no press 1 
            then terminate call with we do not wish to take your call message
            else go to house voice mail 2 and email me

Take this simple example:

exten => s,1,Noop(This line will appear in the Asterisk full log)
exten => s,n,Return

In the Admin GUI, create a Custom Destination that dials test-context,s,1 and, toggle the return and choose the desired destination.

This is by far the simplest way to create an internal FreePBX destination that you can use anywhere in the GUI call flow, have it execute your own custom dialplan, and return back to the GUI to continue the call to another GUI destination.

If you want to branch a call based on a condition, the third party module dynroutes will probably accomplish what you need there.

1 Like

If that dial plan is set as a custom destination and it arrives at exten => s,n,Return, where does it actually return to exactly?

It returns back to the Custom Destination, and you select where the call goes from there in the GUI.

1 Like

Many thanks Lorne. You are showing real dedication help folks at the weekend :slight_smile:

Using Custom Destination is so far working fine for incoming calls - I’ve yet to change outbound. I set the Inbound Route Destination to a Ring Group to handle the “normal” situation, and in the custom code I’m sending some calls to voice mail. Both working OK.

For family members I decided to mark their names in the Whitelist/Phone book with an * (e.g. “*Uncle John” 012345678 and test for the * rather than use dynaroute and a SQL database, but that may prove useful for more complex situations.

The slight downside is the logs are longer :wink:

I’m having a strange situation with Caller ID Name - I’m sure it was working OK before. I’ll make that another post.

Thanks again

1 Like