Source Syntax

The only thing that changes from the Asterisk syntax is the way you mark extensions, contexts, and the references to lines in the same extension, a different extension in the same context, or a different extension in another context.

Currently, the DPC only supports references to lines in the same file.

Basic Syntax

To indicate an extension, use the format X:context:extension. You must always indicate the extension's context.

After that, just type your dialplan code, without the exten => prefix, and without numbering the lines. This is what the compiler will fill in for you later.

Whenever you have a goto or GotoIf command (or any other command) in which you need to make a reference to another line of code, use the reference format (L:label:extension:context). The context and extension are optional; you can just indicate the label, if that label is in the same extension; or indicate the label and the extension, if that extension is in the same context; if the extension is in a different context then you need to use all three components for the reference.

Now, if you have a reference to another line, in that line you need to indicate the label, by prefixing it with the label indicator L:label:.

Example

Here's an example of a simple file in the format for the Dial Plan Compiler. Labels and references are marked in red, while extension headers are marked in blue.

X:example:501 ; some comment for the extension
SetVariable(value=10)
Answer
L:enter-pin:Read(pin,enter-pin,4)
GotoIf($["${pin}" = "1234"]?(L:ok)) ; goto label "ok"
playback(incorrect-pin)
Goto((L:enter-pin))
L:ok:playback(ok)
Goto((L:number:599))
Hangup

X:example:599
NoOp(The password was correct)
L:number:Read(number,enter-number,7)
Dial(SIP/${number},20,t)

The compiler will transform the above code into this Asterisk dial plan code:

[example]
; some comment for the extension
exten => 501,1,SetVariable(value=10)
exten => 501,2,Answer
exten => 501,3,Read(pin,enter-pin,4)
exten => 501,4,GotoIf($["${pin}" = "1234"]?7) ; goto label "ok"
exten => 501,5,playback(incorrect-pin)
exten => 501,6,Goto(3)
exten => 501,7,playback(ok)
exten => 501,8,Goto(599,2)
exten => 501,9,Hangup

exten => 599,1,NoOp(The password was correct)
exten => 599,2,Read(number,enter-number,7)
exten => 599,3,Dial(SIP/${number},20,t)
Dial Plan Compiler
Home
Project Page
Syntax
Download
Asterisk
Digium
Asterisk Wiki
Other projects
JAGI Server
ezContent
iPod xTract
Cemanahuatl
SourceForge.net Logo