Asterisk IP PBX Learning Tutorials - Part 5

This video provides a further explanation: Using Contexts and Dial Plans - Part 1

Contexts and dialplan Part 1

This video will get you introduced to concept of dialplan in asterisk.

The dialplan is a set of instructions in asterisk specific language that tells the system what to do with the call. Dialplan is stored in extension.conf file, so lets open this file and begin.

Dialplan is divided into contexts, and as you can see each context starts with square brackets, just like  extensions, and can have any name. However there are 2 names that are reserved ”general” and “globals”, in “general section” you define general settings of dialplan and in “globals” section you define some global variables that will be used in your dialplan, as an example here TRUNK is a global variable that you can use in your further dialplan, and each occurrence of TRUNK will be replaced with its values which is Zap/G2.

Lets take a look at the examples I have created for our demo. Each context contains some rules on how to process particular call. Each rule is identified by number that have been dialled and consists of number of steps. Each step is starting with “exten” keyword,  followed by that special sign (=>),  followed by number that have been dialled, followed by rule number or priority in asterisk’s terms and followed by action that should be actually taken. Unless explicitly specified rule processing takes place step by step.

Ok, enough theory, lets get to the examples. First context is [incoming-calls], it is that we have used when we defined our extensions. It contains 2 rules, how to dial extension 205 and extension 206. As you can see first step which is done when you dial 205 is to dial sip extension 205. You can set some features for “Dial” function and pass them to it, mine are left by default, so I just skip them. The third parameter is number of seconds to try to dial before giving up and move to next step. 120 seconds or 3 minutes is far more than enough to wait till someone picks up the phone. The next step is “Hangup” instruction, that tells asterisk to hangup call and delete everything related to it. It is wise to end each rule with “Hangup” instruction just to be sure that it will not get into any other rule. The same rule is configured for dialling extension 206. There is also “include” instruction in this dialplan, but lets return to it later.

Related posts:

  1. Asterisk IP PBX Learning Tutorials - Part 6
  2. How to Use Asterisk Software IP PBX - Part 4
  3. Asterisk IP PBX Learning Tutorials - Part 4
  4. How to Use Asterisk Software IP PBX - Part 5
  5. Asterisk IP PBX Learning Tutorials - Part 9

Discussion Area - Leave a Comment

You must be logged in to post a comment.