text stringlengths 0 152 |
|---|
into an Asterisk dialplan on a system that you’ve built from scratch. |
People get this funny grin on their faces as they realize that they |
have just created a telephone system. This pleasure can be yours as |
well, so please, don’t go any further until you have made this little |
bit of dialplan work. If you have any problems, get back to Chap‐ |
ter 5 and work through the examples there. |
If you don’t have this dialplan code built yet, you’ll need to add it and reload the |
dialplan with this CLI command: |
$ sudo asterisk -rvvvvv # ('r' attaches to a daemonized Asterisk; 'v's are for verbosity) |
*CLI> dialplan reload |
or you can issue the command directly from the shell with: |
$ sudo asterisk -rx "dialplan reload" # ('rx' execute an Asterisk command and return) |
Calling extension 200 from either of your configured phones7 should reward you |
with the friendly voice of Allison Smith saying “Hello, World.” |
If it doesn’t work, check the Asterisk console for error messages, and make sure your |
channels are assigned to the sets context. |
We do not recommend that you move forward in this book until |
you have verified the following: |
1. Calls between extension 100 and 101 are working. |
2. Calling extension 200 plays “Hello World.” |
7 If you haven’t configured two phones yet, please consider heading back to Chapter 5 and getting a couple of |
phones set up so you can play with them. You can get away with only one phone for testing, but really two is |
ideal. There are lots of free softphones available, and some of them are rather good. |
88 |
| |
Chapter 6: Dialplan Basics |
Even though this example is very short and simple, it emphasizes the core dialplan |
concepts of contexts, extensions, priorities, and applications. You now have the fun‐ |
damental knowledge on which all dialplans are built. |
As you build out a dialplan, it will be helpful to have the Asterisk CLI open in a new |
window. You will be reloading the dialplan often, and while testing your call flow, you |
will want to see what is happening, as it happens. The Asterisk CLI is useful for both |
of those things. |
$ sudo asterisk -rvvvvv |
*CLI> dialplan reload # this Asterisk CLI command reloads the dialplan |
Best practice, then, would be to edit in one window, and to reload and debug in |
another. |
Building an Interactive Dialplan |
The dialplan we just built was static; it will always perform the same actions on every |
call. Many dialplans will also need logic to perform different actions based on input |
from the user, so let’s take a look at that now. |
The Goto(), Background(), and WaitExten() Applications |
As its name implies, the Goto() application is used to send a call to another part of |
the dialplan. Goto() requires us to pass the destination context, extension, and prior‐ |
ity as arguments, like this: |
same => n,Goto(context,extension,priority) |
We’re going to create a new context called TestMenu, and create an extension in our |
sets context that will pass calls to that context using Goto(): |
exten => 200,1,Answer() |
same => n,Playback(hello-world) |
same => n,Hangup() |
exten => 201,1,Goto(TestMenu,start,1) ; add this to the end of the |
; [sets] context |
[TestMenu] |
exten => start,1,Answer() |
Now, whenever a device enters the [sets] context and dials 201, the call will be |
passed to the start extension in the TestMenu context (which currently won’t do any‐ |
thing interesting because we still have more code to write). |
Building an Interactive Dialplan |
| |
89 |
We used the extension start in this example, but we could have |
used anything we wanted as an extension name, either numeric or |
alpha. We prefer to use alpha characters for extensions that are not |
directly dialable, as this makes the dialplan easier to read. Point |
being, we could have named our target extension 123 or xyz321, or |
99luftballons, or whatever we wanted instead of start. The word |
start doesn’t mean anything special to the dialplan; it’s simply the |
name of an extension. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.