Limit invalid entry in incoming context

Hello pal

if i want to limit the incoming context into 3 invalid trials how to do it?
if im going to use a variable and increment everytime the caller gets wrong and terminate if it reach 3 trials, would it effect with another caller in zap channels as im looking forward to have an 8 FXO thats is 8 trunk lines coming in to my Asterisk server?

thanks

can you explain a bit more clearly what you’re trying to do ? what are “3 invalid trials” ? if Asterisk gets a number from a user that doesn’t match, there’s nothing to see/do.

its like this…
when caller reach to incoming context he has chance to dial any one digit as stated in my IVR. now what i want to limit is if the caller dial a wrong digit (not in my IVR)for three times he/she will be hangup as he/she reach the allowable limit of dialing a certain extension.
if the caller would make a wrong dial for three time the channel being used will be hangup.

i ask this as i have observed “i” will have an infinite loop that keep on saying
an invalid and ask for the right exntension

just increment a variable that’s checked as part of the 'i’nvalid extension, and hangup if it reaches 3, e.g. exten => s,1,NoOp(My IVR) exten => s,2,Answer exten => s,3,Wait(1) exten => s,4,Set(LOOPED=1) exten => s,5,GotoIf($[${LOOPED} > 2]?hang,1) exten => s,6,Set(Timeout(digit)=3) exten => s,7,Set(Timeout(response)=7) exten => s,8,Background(custom/my_ivr) exten => t,1,Set(LOOPED=$[${LOOPED} + 1]) exten => t,2,Goto(s,5) exten => h,1,Hangup exten => hang,1,Playback(vm-goodbye) exten => hang,2,Hangup exten => i,1,Playback(invalid) exten => i,2,Goto(s,6)

OK, this example doesn’t do the increment in ‘i’, but you get the idea !

i got it in anyway and here is my code. please tell me if there is logical error
but as i have tested it i got what i need