Custom Dialplan For Gate Opener

I am trying to activate a custom dialplan to operate a gate opener relay. The relay is working as I can access it through a web page. Various other pages talk about putting a custom dial plan in /etc/asterisk/extensions_custom.conf. But then I guess for FreePBX we use /etc/asterisk/extensions_override_freepbx.conf?

Is that right?

I’ve placed my plan there and created an entry under Misc Apps. But it doesn’t look like my dial plan is being used. Any ideas?

This is my dial plan:

exten => 80,1,System(/var/lib/asterisk/
exten => 80,1,Hangup

Yes, the script works. My misc app is for feature code 80.

And I have a custom destination that looks like:


Putting your code in is fine. This kind of thing is why it’s there.

You don’t have a gateopener,s,1 step. You do have a gateopener,80,1 step though.

Also, you can only have 1 gateopener,80,1 step - you have two. The second one should probably be 80,n,… for the ‘next’ step.

You’ve gotten pretty close. Keep at it.

extensions_custom.conf is where I started. But in extensions.conf I see:

#include extensions_override_freepbx.conf
#include extensions_additional.conf
#include extensions_custom.conf

It is commented out If I manually uncomment it, FreePBX whines about modified files. When I had done this, my dial plan actually was executing. So my question is, how do I create custom dial plans within the FreePBX ecosystem without the system complaining?

Now that I look at this, both extensions_override_freepbx.conf and extensions_custom.conf are commented out. I need to activate one or both. EDIT: I’m told this is correct and the files are indeed activated in Asterisk.

I don’t understand your other points. I thought I was supposed to create both a “Custom Destination” and a “Misc Application” in order to execute a custom dial plan. The “gateopener,s,1” is what I put in the Custom Destination not the dial plan.

#include is a directive

1 Like

Got it. Thanks. My bad. Now if I can get this dial plan working.

Now that I’ve figured out the conf setup I’ve moved my dial plan back to extensions_custom.conf. The “gateopener,s,1” bit was referring to what I setup under Custom Destinations not under my dial plan. I have corrected the dial plan:

exten => 80,1,System(/var/lib/asterisk/
exten => 80,n,Hangup
exten => 80,1,System(/var/lib/asterisk/
exten => 80,1,Hangup

Try this:

exten => s,1,System(/var/lib/asterisk/
exten => s,n,Hangup

With these changes, you now have an Gateopener,s,1 step (you didn’t before) and your script will “hangup” (which it couldn’t before because you had two step ‘1’ instances.

Now, set up your system so that your custom pointers so that “80” points to gateopener,s,1 and you should be good to go.

Okay, will do as soon as I get home. So the context [gateopener] is the “connector” back into FreePBX and not the extension number. I guess that was what was confusing me. I thought I needed the 80 to “find” and execute the dial plan.

That would work if you were adding the dialplan to a context that was already being executed (like “from-internal”). Since you are executing the context directly, you can set it up so that the custom-extension points to the context ‘start’ step.

I don’t understand contexts then. Is there documentation somewhere that explains them? When is “from-internal” executed?

There are several books that cover writing custom contexts, include the classic “Asterisk for Dummies” and their ilk. If you check around the website, I’m pretty sure you’ll find a few wikis that will help. It seems to me that O’Reilly even has one that you can download for free.

If you search google for “asterisk custom context primer”, the first 10 hits are all good places to start - especially the one from the actual website. Contexts are common to all Asterisk implementations, not just FreePBX, so it should be relatively easy to find plenty of documentation.

Nope, still doesn’t work. I dial that extension that I get a busy signal. I’ve placed your revised dial plan in extensions_custom.conf with a context of [gateopener].

I have a custom destination with a target of “gateopener,s,1”.

I have a Misc Application with a feature code setting the extension to dial and the target of that custom destination.

What am I missing?

in extensions_custom.conf put this in with no context then dial *812 (as long as you are not using *812 for something else)
you can take it from there.

exten => *812,1,Playback(zombies)
exten => *812,n,Playback(sendhelp)
exten => *812,n,Hangup


don’t forget to reload dialplan


Oh duh! I forgot to make the script executable! I said the script worked and it did elsewhere. Then I copied it to /var/lib/asterisk and forgot to reset permissions!

The script runs, the gate opens/closes. Next problem: on dialing the extension the phone says “No Response” and gives a busy signal. I thought the hangup would handle this. How can I just execute and gracefully end the call?

Did you try what I said above.


you can give it a context from-internal

exten => *812,1,Playback(zombies)
exten => *812,n,Playback(sendhelp)
exten => *812,n,Hangup


I stumbled across this:

The Asterisk Book

It turns out the Playback command is what was needed. If I add that command then the hangup command works correctly.

This was my next step, playing an acknowledgement sound. Now the collection of recordings in /var/lib/asterisk/sounds/en are vast and fun. But all I really want to do is play a tone. I tried the command “Playtones” but that wasn’t working for some reason.

Anyone know how to play a custom tone instead of a recording?

The answer to getting Playtones to work is to add an answer command. My dial plan now looks like:

exten => s,1,System(/var/lib/asterisk/
exten => s,n,Answer
exten => s,n,Playtones(!425/500,!300/500)
exten => s,n,Wait(1)
exten => s,n,Hangup

Still need the wait command to allow the tones to play. The exclamation mark means the tones do not repeat. Now I can play with the timing and frequency of the sounds.

Thank you everyone for your help!