How to check the majority in the dialplan

Good evening, I would like to ask callers to confirm their majority by pressing the star key on the telephone. How can I do this in a dialplan? If the user presses the star key, he goes to the next context. If the user doesn’t press the star key, we have to repeat the context that asks them to confirm their age by pressing the star key. Do you have any ideas? I’ve got a start: [confirm-majority]
exten => s,1,NoOp(check caller’s age)

  1. What if they don’t enter anything?
  2. What if they enter a key other than star?
  3. You should use the verbose application instead of noop.

The read application sounds like a good place to start.

Well, if they don’t fit, I say we repeat the step or ask for the majority. But isn’t there another way than using read?

If I understand correctly, you need the caller to confirm that they are of legal age before proceeding. Right?

If so, and that is all you need to confirm, a dialplan like the following might give you an idea:

exten => CONFIRMAGE,1,Noop()
same => n,Read(CONFIRM,msg/confirmage,1,4,2)
same => n,GotoIf($[“${CONFIRM}”!=“*”]?1:ELSEWHERE)

In this dialplan, we play a message and accept only one key as input. If the caller enters anything other than “*”, or if they don’t enter anything at all, they will be persistently prompted to confirm their age. Of course, you need to adapt this to your specific context and situation, but this is the basic idea. There are other ways to achieve this, such as using the BackGround() and WaitExten() applications, but using Read() is more straightforward.

Hello, Thank’s you. here’s my dialplan:

[incoming]

exten => s,1,NoOp(incoming call)
same => n,GotoIf($[“${CALLERID(num)}” = “anonymous”]?appel_masque:pas_masque)

; Calls with masked number

same => n(masked_call), Playback(custom/desole_accept_not_masked_call); audio masked call
same => n, Hangup(); call hangs up.

accepts visible numbers

same => n(not_masking), Playback(custom/welcome); here it plays welcome message.
same => n,Wait(2); we wait 2 seconds before the next step.
same => n,Goto(confirmation-majority,s,1); step to check the person’s majority.

[confirmation-majority]
exten => s,1,NoOp(check caller’s age)
same => n,Read(dtmf,custom/confirmation_majorite,1,4,2)
same => n,GotoIf($[“${dtmf}”!=“*”]?menu-main,s,1:ELSEWHERE)

[menu-main]
exten => s,1,NoOp(Access to main menu)
same => n,BackGround(custom/menu_conference) ; Plays conference menu
same => n,WaitExten(5) ; Waits for input for 5 seconds
same => n,Goto(menu-principal,s,1) ; Returns to main menu after input

Pay attention to my example:

same => n,GotoIf($[“${CONFIRM}”!=“*”]?1:ELSEWHERE)

This line indicates that if the content of the variable is DIFERENT FROM “*”, it should return to priority number 1 of the same extension, to start over and ask for confirmation of majority again. Let’s then, based on the information above, reconstruct this line in your dialplan:

same => n,GotoIf($[“${dtmf}”!=“*”]?1:menu-main,s,1)

Again: If the caller didn’t press “*”, it will be sent back to confirmation-majority,s,1. If it did press the star key, it will be sent to menu-main,s,1, which is what I assume you expect to happen.

Thank you very much for your feedback. I modified the dialplan:

[incoming]

exten => s,1,NoOp(incoming call)
same => n,GotoIf($[“${CALLERID(num)}” = “anonymous”]?appel_masque:pas_masque)

; Calls with masked number

same => n(masked_call), Playback(custom/desole_accept_not_masked_call); audio masked call
same => n, Hangup(); call hangs up.

; Accept visible numbers

same => n(not_masking), Playback(custom/welcome); here it plays welcome message.
same => n,Wait(2); we wait 2 seconds before the next step.
same => n,Goto(confirmation-majority,s,1); step to check the person’s majority.

[confirmation-majority]
exten => s,1,NoOp(check caller’s age)
same => n,Read(dtmf,custom/confirmation_majorite,1,4,2)
same => n,GotoIf($[“${dtmf}”!=“*”]?1:menu-principal,s,1)

[menu-principal]
exten => s,1,NoOp(Access to main menu)
same => n,BackGround(custom/menu_conference) ; Plays conference menu
same => n,WaitExten(5) ; Waits for input for 5 seconds
same => n,Goto(menu-principal,s,1) ; Returns to main menu after input

Great! Now it should work as expected.

Just to clarify something: I noticed that when we post dialplans here in this forum, the system makes some modifications to the lines. For instance, in my Read example, it removed a comma from the line. There should be two commas between the numbers 1 and 4.

That’s what the </> preformatted text button is there to stop.

1 Like

Thank you very much for your help yesterday.

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