Sydney Senior SRE/Sysadmin/Something.

Asterisk – Adding Game

· by Robert Mibus · Read in about 1 min · (118 Words)
asterisk sysadmin voip

A quick adding game for Asterisk.

Set up an extension (I used “4263″) to Goto(game,s,1). It will speak two numbers from 1-8, and expects a single key to be pressed for the sum of those two numbers. I’ve only used fairly standard sounds, so there’s no recording involved.

Hoping that my five-year-old enjoys this :)

[game]
exten => s,1,NoOp(GameSTART)
exten => s,n,Set(num1=${RAND(1,8)});
exten => s,n,Set(maxnum2=$[9-${num1}])
exten => s,n,Set(num2=${RAND(1,${maxnum2})})
exten => s,n,Set(total=$[${num1}+${num2}])
exten => s,n(quest),SayNumber(${num1})
exten => s,n,Playback(letters/plus)
exten => s,n,SayNumber(${num2})
exten => s,n,WaitExten

exten => _X,1,NoOp(GameHazDigits)
exten => _X,n,GotoIf($[${EXTEN} = ${total}]?GotItRight)
exten => _X,n(GotItWrong),NoOp(Awww)
exten => _X,n,Playback(privacy-incorrect)
exten => _X,n,Playback(pls-try-again)
exten => _X,n,Goto(s,quest)
exten => _X,n(GotItRight),NoOp(YAY)
exten => _X,n,Playback(yes-dear2)
exten => _X,n,Goto(s,1)

exten => t,1,Goto(s,quest)
exten => i,1,Goto(s,quest)