A quick question. How can i use the GotoIf() after a caller has not given any input. Getting an error message. Which is obvious cause ctbIvrMenuEmployeeByIntroductionUserChoice is not set.
The dialplan
exten => 1,1,Verbose(Ivr menu employee by introduction init)
same => n,Playback(${ctbPromptIvrMenuUserIntroduction});
; set the the data for the first userprompt to play back
same => n,Set(ref=${SHELL(echo '${ctbJsonResult}' | jq '.data.user'${ctbIvrMenuEmployeeByIntroductionUserPromptCounter}.ref | tr -d '\n"')})
; check if the user prompt exist, else set the default user prompt
same => n,Set(ctbUserPrompt=${SHELL(test -e /etc/asterisk/dialplans/chattabai/prompts/user/${ref}.sln && echo /etc/asterisk/dialplans/chattabai/prompts/user/${ref} | tr -d '\n"' || echo /etc/asterisk/dialplans/chattabai/prompts/user/thisUserDoesNotHaveAPrompt | tr -d '\n"')})
same => n,read(ctbIvrMenuEmployeeByIntroductionUserChoice,${ctbUserPrompt},1)
; on 1 forward to the user
same => n,GotoIf($[${ctbIvrMenuEmployeeByIntroductionUserChoice}=1]?ctbIvrMenuEmployeeByIntroductionForwardToUser,1,1:ctbIvrMenuEmployeeByIntroductionUserPrompt,1,7)
; on 2 goto the next user
same => n,GotoIf($[${ctbIvrMenuEmployeeByIntroductionUserChoice}=2]?ctbIvrMenuEmployeeByIntroductionUserPrompt,1,8:ctbIvrMenuEmployeeByIntroductionUserPrompt,1,11)
same => n,Verbose(Ivr menu employee by introduction going to the next user)
same => n,Set(ctbIvrMenuEmployeeByIntroductionUserPromptCounter=${MATH(${ctbIvrMenuEmployeeByIntroductionUserPromptCounter}+1)})
same => n,Goto(ctbIvrMenuEmployeeByIntroductionUserPrompt,1,3)
; on 9 goto the main menu
same => n,GotoIf($[${ctbIvrMenuEmployeeByIntroductionUserChoice}=9]?ctbIvrMenuEmployeeByIntroductionUserPrompt,1,1:ctbIvrMenuEmployeeByIntroductionUserPrompt,1,12)
; no valid choice given go back to ivr menu employee by introduction
same => n,Playback(${ctbPromptThisIsAnInvalidOption})
same => n,Goto(ctbIvrMenuEmployeeByIntroductionUserPrompt,1,1)
The log
-- Executing [1@ctbIvrMenuEmployeeByIntroductionUserPrompt:3] Set("PJSIP/local2-00000027", "ref=000048") in new stack
-- Executing [1@ctbIvrMenuEmployeeByIntroductionUserPrompt:4] Set("PJSIP/local2-00000027", "ctbUserPrompt=/etc/asterisk/dialplans/chattabai/prompts/user/000048") in new stack
-- Executing [1@ctbIvrMenuEmployeeByIntroductionUserPrompt:5] Read("PJSIP/local2-00000027", "ctbIvrMenuEmployeeByIntroductionUserChoice,/etc/asterisk/dialplans/chattabai/prompts/user/000048,1") in new stack
-- Accepting a maximum of 1 digits.
-- <PJSIP/local2-00000027> Playing '/etc/asterisk/dialplans/chattabai/prompts/user/000048.slin' (language 'en')
-- User entered nothing.
[May 10 01:14:34] WARNING[2401014][C-00000026]: ast_expr2.fl:470 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected '=', expecting $end; Input:
=1
^
[May 10 01:14:34] WARNING[2401014][C-00000026]: ast_expr2.fl:474 ast_yyerror: If you have questions, please refer to https://wiki.asterisk.org/wiki/display/AST/Channel+Variables
-- Executing [1@ctbIvrMenuEmployeeByIntroductionUserPrompt:6] GotoIf("PJSIP/local2-00000027", "?ctbIvrMenuEmployeeByIntroductionForwardToUser,1,1:ctbIvrMenuEmployeeByIntroductionUserPrompt,1,7") in new stack
-- Goto (ctbIvrMenuEmployeeByIntroductionUserPrompt,1,7)
[May 10 01:14:34] WARNING[2401014][C-00000026]: ast_expr2.fl:470 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected '=', expecting $end; Input:
=2
^
[May 10 01:14:34] WARNING[2401014][C-00000026]: ast_expr2.fl:474 ast_yyerror: If you have questions, please refer to https://wiki.asterisk.org/wiki/display/AST/Channel+Variables
-- Executing [1@ctbIvrMenuEmployeeByIntroductionUserPrompt:7] GotoIf("PJSIP/local2-00000027", "?ctbIvrMenuEmployeeByIntroductionUserPrompt,1,8:ctbIvrMenuEmployeeByIntroductionUserPrompt,1,11") in new stack
-- Goto (ctbIvrMenuEmployeeByIntroductionUserPrompt,1,11)
[May 10 01:14:34] WARNING[2401014][C-00000026]: ast_expr2.fl:470 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected '=', expecting $end; Input:
=9
^
[May 10 01:14:34] WARNING[2401014][C-00000026]: ast_expr2.fl:474 ast_yyerror: If you have questions, please refer to https://wiki.asterisk.org/wiki/display/AST/Channel+Variables
-- Executing [1@ctbIvrMenuEmployeeByIntroductionUserPrompt:11] GotoIf("PJSIP/local2-00000027", "?ctbIvrMenuEmployeeByIntroductionUserPrompt,1,1:ctbIvrMenuEmployeeByIntroductionUserPrompt,1,12") in new stack
-- Goto (ctbIvrMenuEmployeeByIntroductionUserPrompt,1,12)
-- Executing [1@ctbIvrMenuEmployeeByIntroductionUserPrompt:12] Playback("PJSIP/local2-00000027", "/etc/asterisk/dialplans/chattabai/prompts/en/thisIsAnInvalidOption") in new stack
-- <PJSIP/local2-00000027> Playing '/etc/asterisk/dialplans/chattabai/prompts/en/thisIsAnInvalidOption.slin' (language 'en')
-- Executing [1@ctbIvrMenuEmployeeByIntroductionUserPrompt:13] Goto("PJSIP/local2-00000027", "ctbIvrMenuEmployeeByIntroductionUserPrompt,1,1") in new stack
-- Goto (ctbIvrMenuEmployeeByIntroductionUserPrompt,1,1)
-- Executing [1@ctbIvrMenuEmployeeByIntroductionUserPrompt:1] Verbose("PJSIP/local2-00000027", "Ivr menu employee by introduction init") in new stack
Ivr menu employee by introduction init
-- Executing [1@ctbIvrMenuEmployeeByIntroductionUserPrompt:2] Playback("PJSIP/local2-00000027", "/etc/asterisk/dialplans/chattabai/prompts/en/ivrMenuUserIntroduction") in new stack
-- <PJSIP/local2-00000027> Playing '/etc/asterisk/dialplans/chattabai/prompts/en/ivrMenuUserIntroduction.slin' (language 'en')
-- Executing [1@chattabai:1] Answer("PJSIP/local2-00000028", "") in new stack
> 0xffff700bf4b0 -- Strict RTP learning after remote address set to: 190.88.119.147:62858
> 0xffff700bf4b0 -- Strict RTP qualifying stream type: audio
> 0xffff700bf4b0 -- Strict RTP switching source address to 172.16.171.1:62858