In part 1, we were discussing the basics of how the Asterisk dialplan works. To recap: asterisk is made up of contexts, which can in turn include more context, creating the whole dialplan. FreePBX takes advantage of this structure by creating a lot of contexts and then included these in each other. Until now, the easiest way to include your own custom dialplan was to put it in one of custom context that FreePBX intentionally leaves blank for the purpose of customization. Now (actually since version 2.3) FreePBX includes a module to make the process easier, simpler and cleaner.
To include your own dialplan in the call flow, we use a combination of modules. First, we need to tell FreePBX where in our dialplan we would like to point to. To do this, we set up a Custom Destination (from the tools tab) with the custom description pointing to out custom dialplan in the format of
context, extension, priority. To refer back to our previous example, we would set the custom destination to:
. We will also add a Description so that we can easily remember what this dialplan refers to. Lets call it
play-monkeys. Then click submit.
Next, we need to create a Miscellaneous Application. The Misc Application module allows us to set up an extension (remember, in Asterisk an extension is somewhere in the dialplan that you can call - not necessarily a phone) that can point to anywhere. For example, if you want your users to be able to call an IVR which is usually only heard by inbound callers, you can set a feature code to call the IVR every time the feature code is dialed. Now we will set up a feature code to call out custom context: Click Misc Application from the setup tab, and enter a feature code, say
11234. Next Enter a description, say
call monkeys. Finally, chose our custom Application form the Destination menu
Custom Application: play-monkeysand finally click submit. Now your all set! Reload FreePBX by clicking the orange bar, and call
11234- you should hear the tt-monkeys file being played back!
There is one more thing to keep in mind. Sometimes, for whatever reason, you don't want to call your custom dialplan directly from FreePBX. Nevertheless, it is important to make sure that you don't accidentally assign a duplicate extension in both FreePBX and the dialplan. Being that FreePBX automatically picks a lot of the extensions it assigns, we need to let it know which extensions NOT to use. To do that, we use the Custom Extension module (tools tab), and we enter the extension number we want to prevent FreePBX from using. This will prevent FreePBX from chosing an extension that you already assigned manually in the dialplan.
That's all. Be sure to check back again next week for a tip on how to list all of the contexts and their includes from the dialplan!
Moshe Brevda, FreePBX Development Team
lazytt - FreePBX forums
hi365 - IRC