I would like to be able to repeat an automatic message set in dialplan n times. So far, I’ve managed to play an endless loop with the following:
[emergency_112]
exten => _[67]XXXXXXXX,1,NoOP(Llamadas por alarma)
same => n,Set(CHANNEL(language)=es_ES)
same => n,Set(CALLERID(all)=${my_number} <${my_number}>)
same => n,NoOp(CALLERID(all))
same => n(message),agi(googletts.agi,"Mensaje",es)
same => n,Goto(message)
same => n,Hangup(21)
However, I don’t know how to finish the loop. I have checked the documentation and I don’t find a way to cancel the “Goto” line after a specific number of times, although I am not an Asterisk specialist and I am perhaps missing some command or dialplan flow for this. Any suggestion, please?
Thank you. Tried this (which it makes sense to me) but it doesn’t work. Message is not repeated. Any advise, please?
[emergencia_real]
exten => _[67]XXXXXXXX,1,NoOP(Llamadas por alarma)
same => n,Set(CHANNEL(language)=es_ES)
same => n,Set(CALLERID(all)=${callerid} <${callerid}>)
same => n,NoOp(CALLERID(all))
same => n,Set(COUNT=1)
same => n(message),agi(googletts.agi,"ATENCIÓN: POR FAVOR, NO CUELGUE.",es)
same => n,Set(TOTAL=${${COUNT}+1})
same => n,GotoIf(${TOTAL}=3?hangup:message)
same => n(hangup),1,Hangup(21)
For anyone’s reference, after some trial/errors and debugging the diaplan with NoOP’s, I realized that the variable count was considered text, so all “+1” strings were being attached “as is” to the previous result. Finally achieved this with the following using the MATH function:
[emergencia_real]
exten => _[67]XXXXXXXX,1,NoOP(Llamadas por alarma)
same => n,Set(CHANNEL(language)=es_ES)
same => n,Set(CALLERID(all)=${callerid} <${callerid}>)
same => n,NoOp(CALLERID(all))
same => n,Set(count=0)
same => n(message),agi(googletts.agi,"MENSAJE",es)
same => n,Set(count=${MATH(${count}+1,int)})
same => n,NoOP(${count})
same => n,GotoIf($[${count}=3]?hangup:message)
same => n(hangup),Hangup(21)
Message is played three times as expected and then call is hanged up.
Agree, but it didn’t work when I tried earlier for whatever reason. I guess I made some mistake with some bracket or parenthesis because now it works with your suggestion. Thank you for taking some time to type the full solution.
For future reference, pasting below the full context dialplan block:
[emergencia_real]
exten => _[67]XXXXXXXX,1,NoOP(Llamadas por alarma)
same => n,Set(CHANNEL(language)=es_ES)
same => n,Set(CALLERID(all)=${callerid} <${callerid}>)
same => n,NoOp(CALLERID(all))
same => n,DBdeltree(lastcallerout)
same => n,set(DB(lastcallerout/lastcallerout)=${EXTEN})
same => n,Set(count=0)
same => n(message),agi(googletts.agi,"WHATEVER MESSAGE",es)
same => n,Set(count=$[ ${count} + 1 ])
same => n,NoOP(${count})
same => n,GotoIf($[${count}=3]?hangup:message)
same => n(hangup),Hangup(21)