GotoIf insdie the While loop in Asterisk dialplan is not working

Below dial plan is not working as expected. After waiting 4 seconds in WaitExten it supposed to go timeout (t) exten if no DTMF pressed in the mentioned time but its going limit_exceed exten.

GotoIf is inside the While loop, this could be the reason or my logic is wrong? Please help to identify.

exten = s,n,While($[${limit} <=${Today_Quiz_Right_Ans_Limit}])
exten = s,n,GotoIf($[${COUNTER}<=${TotalFiles}]?continue:limit_exceed)
exten = s,n(continue),Background(RBI_PORTAL/SPORTS_22020/beach_cricket_quiz_campaign/${COUNTER})
exten = s,n(continue),WaitExten(4)
exten = s,n(limit_exceed),Playback(RBI_PORTAL/SPORTS_22020/prompts/Global_Prompt/Quiz_Prompts/Todays_Limit_Exceed)
exten = s,n(limit_exceed),Goto(ROBI_SPORTS_22222_MAIN_MENU,s,1)
exten = s,n,EndWhile()

You have set the same name on two different priorities, twice.

WaitExten drops through when the timeout parameter is exceeded. If you want to goto the t extension you will need to follow it with a Goto that extension.

1 Like

Thank you for your response. Would you please make me clarify what is “Goto tot hat extension”? I’m newbie in asterisk, unable to understand that what you said. Or please give me an example if possible.

That was a typo, now corrected.

Goto(t,1) However, I’ve never used While so I don’t know how Asterisk handles jumps out of loops.

1 Like

I’m going to go with that WaitExten is just waiting, it doesn’t “timeout” as in jump to the t extension. It waits for x seconds for inputs then continues. Even the example shows a GoTo running after the WaitExten to handle timeouts. Try using Set(Timeout(response)=4) before the playback/waitexten.

Also is this a GoSub() or a Macro()? WaitExten doesn’t function properly in a Macro(), you should use READ() if this is a Macro().

1 Like

I just set in below and its working fine now. Thanks David.

exten = s,n(continue),WaitExten(4)
exten = s,n(continue),Goto(ROBI_CRIC_QUIZ_PLAY_22222,t,1)

Thank you for your response. I have already resolved my issue by following David’s instruction. Your instruction also should work as you said in below. Thank you very much.

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