Each Asterisk contexts in extensions.conf may have an ‘i’ extension that is used for invalid extensions, i e, non-existing extensions dialled by clients.
Not Automatic
You would think that Asterisk would automatically jump to the ‘i’ extension if the client dials a number that is not matched by any other extensions. But it doesn’t. Take this simple example:
exten => 1,1,Dial(Zap/3,20)
exten => 2,1,Dial(Zap/4,20)
exten => i,1,Answer
exten => i,2,Playback(pbx-invalid)
exten => i,3,Hangup
If the client dials ‘1’ or ‘2’, all is well; they are connected to the appropriate extension. But if they dial ‘3’, asterisk does not jump to the ‘i’ extension and play the “pbx-invalid” sound file.
The ‘i’ extension only gets fired when there’s a prompt or input been made with ‘background’. You can set up a ‘exten => i,1…’ to prompt for wrong keypresses – insult the user and so on. So this wont work if someone just dials somthing wrong.
Where’s the original number?
The original number dialled is found in the channel variable ${INVALID_EXTEN}
Alternative to i
Include a separate (!) context like below to catch all other = non-existing extensions:
[bogons]
exten => _.,1,what_to_do_for_fat_fingers_always_misdialing
EDIT:
For not trapping into the same extension twice if a user hangs up (when not defined a h extension),
you just could use _X. instead of _. so you only catch the numeric calls (X = 0..9 and not h, i or whatever).
Alternative NOT using ‘i’
it works great!
Trapping for incorrectly dialed extentions.
Howto get ‘i’ working in your dialplan
So after much frustration and poking around I have figured out howto get an ‘i’ extension to register with your dialplan. The problem is that when a channel enters a context it does not honor ‘i’ for some reason, but if you’re used to using macro’s and Goto/GoSub you’ll know that the ‘i’ extension works there. The solution is then to Goto/GoSub from a stub extension to your real extension.
For instance if your SIP users end up in a context-named “sip-users” you could configure something like:
[sip-users]
exten => _.,1,Goto(local-users,BYEXTENSION,1)
[local-users]
exten => 1,1,Dial(Zap/3,20)
exten => 2,1,Dial(Zap/4,20)
exten => i,1,Answer
exten => i,2,Playback(pbx-invalid)
exten => i,3,Hangup
Triggered by Other Commands
The following Asterisk commands can automatically trigger the ‘i’ extension