Chapter 6. Dialplan Basics

Table of Contents

Dialplan Syntax
Contexts
Extensions
Priorities
Unnumbered priorities
The 'same =>' operator
Priority labels
Applications
The Answer(), Playback(), and Hangup() Applications
A Simple Dialplan
Hello World
Building an Interactive Dialplan
The Goto(), Background(), and WaitExten() Applications
Handling Invalid Entries and Timeouts
Using the Dial() Application
Argument 1: Destination
Argument 2: Timeout
Argument 3: Option
Argument 4: URI
Updating the dialplan
Blank arguments
Using Variables
Global variables
Channel variables
Environment variables
Adding variables to our dialplan
Pattern Matching
Pattern-matching syntax
Pattern-matching examples
Using the ${EXTEN} channel variable
Includes
Conclusion

Everything should be made as simple as possible, but not simpler.

Albert Einstein

The dialplan is the heart of your Asterisk system. It defines how calls flow into and out of the system. A form of scripting language, the dialplan contains instructions that Asterisk follows in response to external triggers. In contrast to traditional phone systems, Asterisk’s dialplan is fully customizable.

This chapter introduces the essential concepts of the dialplan. The information presented here is critical to your understanding of dialplan code and will form the basis of any dialplan you write. The examples have been designed to build upon one another, and we recommend that you do not skip too much of this chapter, since it is so fundamentally important to Asterisk. Please also note that this chapter is by no means an exhaustive survey of all the possible things dialplans can do; our aim is to cover just the essentials. We’ll cover more advanced dialplan topics in later chapters. You are encouraged to experiment.