text stringlengths 0 152 |
|---|
exten => _0X.,1,noop() ; national dialing prefix |
; Dutch Caribbean (Saba) |
exten => _00X.,1,noop() ; international |
exten => _416XXXX,1,noop() ; local (on-island) |
exten => _0[37]XXXXXX,1,noop() ; call to country code 599 off-island (not Curacao) |
exten => _09XXXXXXX,1,Noop() ; call to country code 599 off-island (Curacao) |
You will need to understand the dialing plan of your region in order to produce a |
useful pattern match. |
Using the ${EXTEN} channel variable |
So what happens if you want to use pattern matching but need to know which digits |
were actually dialed? Enter the ${EXTEN} channel variable. Whenever you dial an |
extension, Asterisk sets the ${EXTEN} channel variable to the digits that were received. |
We used the application SayDigits() to demonstrate this. |
19 If you grew up in North America, you may believe that the 1 you dial before a long-distance call is “the long- |
distance code.” This is not completely correct. The number 1 is also the international country code for NANP. |
Keep this in mind if you send your phone number to someone in another country. The recipient may not |
know your country code, and thus be unable to call you with just your area code and phone number. Your full |
phone number with country code is +1 NPA NXX XXXX (where NPA is your area code)—for example, |
+1 416 555 1212. This is also known as E.164 format (Wikipedia can tell you all about E.164). |
104 |
| |
Chapter 6: Dialplan Basics |
exten => _4XX,1,Noop(User Dialed ${EXTEN}) |
same => n,Answer() |
same => n,SayDigits(${EXTEN}) |
same => n,Hangup() |
exten => _555XXXX,1,Answer() |
same => n,SayDigits(${EXTEN}) |
In these examples, the SayDigits() application read back to you the extension you |
dialed. |
Often, it’s useful to manipulate the ${EXTEN} by stripping a certain number of digits |
off the front of the extension. This is accomplished by using the syntax ${EXTEN:x}, |
where x is where you want the returned string to start, from left to right. For example, |
if the value of ${EXTEN} is 95551212, ${EXTEN:1} equals 5551212. Let’s try another |
example: |
exten => _XXX,1,Answer() |
same => n,SayDigits(${EXTEN:1}) |
In this example, the SayDigits() application would start at the second digit, and thus |
read back only the last two digits of the dialed extension. |
More Advanced Digit Manipulation |
The ${EXTEN} variable properly has the syntax ${EXTEN:x:y}, where x is the starting |
position and y is the number of digits to return. Given the following dial string: |
94169671111 |
we can extract the following digit strings using the ${EXTEN:x:y} construct: |
• ${EXTEN:1:3} would contain 416 |
• ${EXTEN:4:7} would contain 9671111 |
• ${EXTEN:-4:4} would start four digits from the end and return four digits, giv‐ |
ing us 1111 |
• ${EXTEN:2:-4} would start two digits in and exclude the last four digits, giving |
us 16967 |
• ${EXTEN:-6:-4} would start six digits from the end and exclude the last four dig‐ |
its, giving us 67 |
• ${EXTEN:1} would give us everything after the first digit, or 4169671111 (if the |
number of digits to return is left blank, it will return the entire remaining string) |
This is a very powerful construct, but most of these variations are not very common |
in normal use. For the most part, you will be using ${EXTEN} (or perhaps ${EXTEN:1} |
if you need to strip off an external access code, such as a prepended 9). |
Building an Interactive Dialplan |
| |
105 |
Includes |
Asterisk has an important feature that allows extensions from one context to be avail‐ |
able from within another context. This is accomplished through use of the include |
directive, which allows us to control access to different sections of the dialplan. |
The include statement takes the following form, where context is the name of the |
remote context we want to include in the current context: |
include => context |
Including one context within another context allows extensions within the included |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.