Asterisk dialpaln [context] : context in asterisk dialpaln

Contexts

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:

[incoming]

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.

Related Posts

  • 55
    Dialplan Introduction:  
    Tags: dialplan, asterisk
  • 42
    In 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…
    Tags: context, asterisk
  • 40
    ChannelRedirect : This is used to redirect the given channel to target dialplan. For example if you want to redirect the channel SIP/1222-09992 to wrap context at 2 priority. You can use this function/command to do so. This has been added in Asterisk 1.4 version. For Asterisk 1.4 version ChannelRedirect(channel|[[context|]extension|]priority)…
    Tags: asterisk, context, dialplan
  • 38
    We often require to do string manipulation on a variable. For example, a variable named phonenumber which represents a number we'd like to call, and we want to strip off the first 5 digit before dialing the number. Asterisk provides a special syntax for doing just that, which looks like ${variable[:skip[:length]} The…
    Tags: asterisk, dialplan
  • 35
    Pre-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…
    Tags: dialplan, asterisk

Satya Prakash

VOIP Expert: More than 8 years of experience in Asterisk Development and Call Center operation Management. Unique Combination of Skill Set as IT, Analytics and operation management.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: