Asterisk read maxlimit


I want to listen to the announcement when the asterisk read digital number limit is exceeded. For example: You entered an incorrect number.

The number entered must be 11 digits. If it exceeds 11 digits, an error message should appear. I have an example below.

exten => XXXXXXX,1,Goto(s,1)
exten => s,1,Answer()
exten => s,2,Playback(/var/lib/asterisk/ivr/ob1)
exten => s,4,Read(digits)
exten => s,5,System(/app/ ${digit} > /tmp/log1.log)
exten => s,6,Hangup()

How can I listen to the error announcement when it exceeds 11 digits?


How is this different than your other post today?

I think you’re missing a couple of pieces that could be remedied by reading about dialplan and dialplan applications.

Your dialplan snippet doesn’t do what you describe.

If you wish to post dialplan snippets, please consider using ‘dialplan show <context-name>’ using the ‘preformatted text’ button.

What you think you are telling Asterisk will do is less interesting that what you told Asterisk to do :slight_smile:

For example, you’re missing ‘s,3’ above and I suspect you need to be consistent with variable names.


Warning if it exceeds 11 digits I want. I did the following for this. But it didn’t work :slight_smile:

exten => XXXXXX,1, Goto (s, 1)
exten => s, 1, Answer ()
exten => s, 2, Background (/var/lib/asterisk/moh/macroform-the_simplicity.wav)
exten => s, 3, Playback (/var/lib/asterisk/ivr/anonce1)
exten => s, 4, Playback (beep)
exten => s, 5, Read (digits , 11)
exten => s, 6, GotoIf ( [ {digits} = 11]? ok: no)
exten => s, 7(no),Playback (/var/lib/asterisk/ivr/invaildvoice)
exten => s, 8 (ok),Goto (9)
exten => s, 9,System (/tmp/ $ {digits}> /tmp/log1.log)
exten => s, 10,Playback (/var/lib/asterisk/ivr/controlanonce)
exten => s, 11,Hangup ()

Again, I think ‘dialplan show <x>’ in ‘preformatted text’ may be more useful.

You’re missing a ‘dollar sign.’

You have a space between a dollar sign and it’s open brace.

You’re comparing the value of a variable with 11, not the length of the variable. Also, if you want to test if a variable is longer than 11 digits, you must allow more than 11 digits. What do you want to do if it is less than 11 digits? As written (assuming you figure out how to test the length of a variable), anything less than 11 gets ‘invalidvoice’ as well.

You’re missing an argument in read().

You’re using background()/playback() in ways that seem odd and unlikely to give you the caller experience you desire.

You’re using the ‘s’ extension in a non-typical way. Not wrong, just confusing. ‘s’ actually means something specific in most dialplans.

Both ‘yes’ and ‘no’ end up at step 9. Is that consistent with the caller experience you desire?

Have you tried executing this? It certainly won’t do as you expect as presented.

Also “it didn’t work” without a ‘preformatted text’ console log doesn’t give anyone much to work with.

I think you would benefit from taking a step back, think about what you want to accomplish, reading about dialplan and dialplan applications, and trying before posting.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.