Skip to end of metadata
Go to start of metadata

 

To set the stage for our explanation of include statements, let's say that we want to organize our dialplan and create a new context called features. We'll leave our extensions 6001 and 6002 for Alice and Bob in the users context, and place extensions such as 6500 in the new features context. When calls come into the users context and doesn't find a matching extension, the include statement tells Asterisk to also look in the new features context.

The syntax for an include statement is very simple. You simply write include => and then the name of the context you'd like to include from the existing context. If we reorganize our dialplan to add a features context, it might look something like this:

Location of Include Statements

Icon

Please note that in the example above, we placed the include statement before extensions 6001 and 6002. It could have just as well come after.
The order in which Asterisk tries to find a matching extension is always current context first, then all the include statements.

Be careful with overlapping patterns/extensions

Icon

Because Asterisk doesn't stop processing the dialplan after the first matching extension is found, always ensure that you don't have overlapping patterns or duplicate extensions among included contexts, or else you'll get an unexpected behavior.
To prevent convoluted bugs it's recommended to end each extension with a Hangup call to explicitly exit the dialplan.

How calling 6001 may go wrong
  • No labels