Dialplans are broken into sections called contexts. Contexts are named groups of extensions, which serve several purposes.
1. Contexts keep different parts of the dialplan from interacting with one another.
2. An extension that is defined in one context is completely isolated from extensions in any other context, unless interaction is specifically allowed.
3. As a simple example, let’s imagine we have two companies sharing an Asterisk server.If we place each company’s voice menu in its own context, they are effectively separated from each other. This allows us to independently define what happens when, say, extension 0 is dialed: people pressing 0 at Company A’s voice menu will get Company A’s receptionist, and callers pressing 0 at Company B’s voice menu will get Company B’s receptionist. (This example assumes, of course, that we’ve told Asterisk to transfer the calls to the receptionists when callers press 0.)
Contexts are denoted by placing the name of the context inside square brackets ([ ]).
The name can be made up of the letters A through Z (upper- and lowercase), the numbers 0 through 9, and the hyphen and underscore.* For example, a context for incoming calls looks like this:
Please not New things about context
- Space is conspicuously absent from the list of allowed characters. Don’t use spaces in your context names
- Context names have a maximum length of 79 characters (80 characters –1 terminating null)
- All of the instructions placed after a context definition are part of that context, until the next context is defined. At the beginning of the dialplan, there are two special contexts named [general] and [globals]. The [general] section contains a list of general dialplan settings
- you may name your contexts anything you like.
When you define a channel (which is how you connect things to the system), one of the parameters that is defined in the channel definition is the context. In other words, the context is the point in the dialplan where connections from that channel will begin.
Another important use of contexts (perhaps the most important) is to provide security.
By using contexts correctly, you can give certain callers access to features (such as longdistance calling) that aren’t made available to others. If you don’t design your dialplan carefully, you may inadvertently allow others to fraudulently use your system. Please keep this in mind as you build your Asterisk system.
- 42In Asterisk, a macro is a special kind of context which can be expanded within the definition of another context. Its name must begin with “macro-”. A macro is expanded by using the Macro command. All the lines of the macro definition should only use the s extension; the actual extension will come from the line in the calling context on…
- 35Pre-dial handlers allow you to execute a dialplan subroutine on a channel before a call is placed but after the application performing a dial action is invoked. This means that the handlers are executed after the creation of the caller/callee channels, but before any actions have been taken to actually…
- 31What is Asterisk? Asterisk is an open source framework for building communications applications. Asterisk turns an ordinary computer into a communications server. Asterisk powers IP PBX systems, VoIP gateways, conference servers and other custom solutions. It is used by small businesses, large businesses, call centers, carriers and government agencies, worldwide.…
- 30Dial() is perhaps the most important application in Asterisk. Dial() accepts every valid channel type (e.g. SIP, IAX2, H.323, MGCP, Local, Zap, Dahdi), The allowable parameters are channel-specific; i.e., what parameters a channel requires or will accept depends on the nature of the channel technology. For example, a SIP channel will require an IP address…