planetWayne.com - Forums
Rants and Raves and Generally Anything
Trapping for incorrectly dialed extentions.

 
Post new topic   Reply to topic    planetWayne.com - Forums Forum Index -> VoIP
View previous topic :: View next topic  
Author Message
planetWayne
Site Admin


Joined: 30 Jan 2003
Posts: 280

PostPosted: Tue Jun 07, 2005 11:50 pm    Post subject: Trapping for incorrectly dialed extentions. Reply with quote

Had a question posted to the forums asking how to play a sound when dialing an incorrect extension, after a bit of playing around (and head scratching - more later) I have a working example.

Basicly the 'i' extention only gets fired when theres 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.

Fine. Got it so far...

Well... Theres a suggestion that was made here but wasnt very clear. So having played around with the idea, came up with the following.


Ok, First create yourself a context. All this takes place in your 'extentions.conf' file My example is called [phatphingers] and stick the following commands in there.
Code:
[phatphingers]
exten => _.,1,answer
exten => _.,2,wait(.5)
exten => _.,3,playback(vm-extension)
exten => _.,4,sayalpha(${EXTEN})
exten => _.,5,playback(invalid)
exten => _.,6,hangup


This works by trapping any dialed 'number' (with the '_.') and runs through the above. It basically announces the extention you dialed and tells you that it was invalid. Ive used the standard sound files that exist with Asterisk to make it easier to implement. Change as you need.

In your context that has your phones in you also need to add the
Code:
include => phatphingers
line as your last included section. This makes sure that this gets called after your extentions get checked and any other includes that come befor it. Check out Sort Order of Extension Patterns

The order is key as, get this in the wrong place, and you wont be able to dial correctly.

NOTE:
As I said above - this looks for any undefined extentions! (get the point)

I found out, after mucho head scratching and wondering why this new context was always getting called twice, IF YOU HAVNT DEFINED A 'H' (HANGUP) EXTENTION IN YOUR PHONE CONTEXT THEN THIS ALSO GETS CALLED TO HANGUP THE CALL. AND every other extention that hangs up when finished will also end up calling this new context (remember we're matching everthing not explicitly defined now!)

Therefor...
Make sure you have a
Code:
exten => h,1,hangup
defined in your phones section of your context.

I've done a
Code:
exten => h,1,playback(goodbye)
exten => h,2,hangup
just to annoy people more Smile - now every time a hangup event happens, Asterisk now says goodbye Laughing


Hope this is usefull!
Back to top
View user's profile Send private message Visit poster's website
luismanson
planetFreshman


Joined: 02 Jun 2005
Posts: 2

PostPosted: Sun Jun 12, 2005 7:00 am    Post subject: Wow! Reply with quote

Thanks You, Thank You, Thank You!!!!! Very Happy
it works great!
Back to top
View user's profile Send private message
planetWayne
Site Admin


Joined: 30 Jan 2003
Posts: 280

PostPosted: Mon Jun 13, 2005 12:18 am    Post subject: Reply with quote

No problems!

Hope it works out for you Smile

Wayne.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    planetWayne.com - Forums Forum Index -> VoIP All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group