Extension Manipulation

Synopsis: 
Extension manipulation lets you influence dialed numbers to create a more dynamic dial plan.

How To Use:
The number dialed is matched against rules that manipulate the number to produce a new number. The new number is further processed as if it where the original number dialed with the exception that it must be matched at the next priority level from which it was created. 

For example, lets say the first priority of extension XXX is to strip the leading digit; then, the resulting number would be matched at the second priority level of XX.

If there is no match for the new number then it is treated as though an invalid number was dialed.

Asterisk provides applications for removing digits (StripMSD and StripLSD) and for adding digits (Prefix).

Stripping Digits
StripMSD removes leading digits while StripLSD removes ending digits. In both cases the number of digits stripped is specified. 

So for example, the number 5551212 when stripped of its leading three digits with StripMSD becomes 1212 and when striped of its ending four digits with StripLSD becomes 555.

Syntax:  
exten => _[Extension],[Priority],[Application],[Count]

Extension	- Number that must be matched.	
Priority  	- Order of evaluation within rule set.	
Application	- StripMSD or StripLSD.	
Count	- Number of digits to strip.	

Examples (StripMSD - Using 9 to reach an outside line):
A common use of stripping is to remove 9 from an internally dialed number before routing the call to an outside line.

exten => _9NXXXXXX,1,StripMSD,1
exten => _NXXXXXX,1,Playback,MustDialNineFirst
exten => _NXXXXXX,2,Dial,Zap/1/BYEXTENSION

Here the first rule strips 9 from the number resulting in NXXXXXX. The new number then matches with the third rule and the call is routed to an outside line.  The second rule illustrates that if a 9 where not dialed first then a message is played instructing the caller to do so.

Examples (StripLSD):

Adding Digits
Prefix appends digits to the beginning of an extension. So for example, the number 1212 when prefixed with 555 will become 5551212.

Format: exten => _[Extension],[Priority],[Application],[Count]

Extension	- Number that must be matched.	
Priority  	- Order of evaluation within a rule set.	
Application	- Prefix.	
Digits  	- Numbers appended to beginning of matched extension.	

Examples (Prefix - Dialing remote office as if local):
Lets say you have two offices that wish to call each other by entering the others extension without area code or anything else. If the second office has extension 54XX and the fully qualified numbers are 503-749-54XX then the rule set for the first office would look something like this:

exten => _54XX,1,Prefix,1503749
exten => _150374954XX,2,Dial,Zap/1/BYEXTENSION

This would allow persons in the first office to dial the second by entering 54XX.

More Examples