Small game in asterisk dialplan

I share a little game in Asterisk Dialplan. It’s been a few years since I made it but here it is for Christmas 🎅🌲.

The goal is to find a digit chosen randomly between 00 and 99, using the keys of his phone.

To use it quickly on XiVO you can:

  • add the code into the Dialplan via the web interface
  • upload the following files start, upper, lower, and end in wav format Microsoft PCM, 16 bit, mono 8000 Hz

Once done, to play the game you just have to call 7 on your IPBX.

exten = 7,1,NoOp(##### Dial plan game #####)
exten = 7,n,Playback(/var/lib/xivo/sounds/playback/start)
exten = 7,n,Set(magic=${RAND(00,99)})
exten = 7,n(begin),NoOp(MAGIC = ${magic})
exten = 7,n,Read(try,,2,,,10)
exten = 7,n,GotoIf( $[${try} > ${magic}]?lower)
exten = 7,n,GotoIf( $[${try} < ${magic}]?upper)
exten = 7,n,GotoIf( $[${try} = ${magic}]?win)

exten = 7,n(lower),NoOp(##### Uper #####)
exten = 7,n,Playback(/var/lib/xivo/sounds/playback/upper)
exten = 7,n,Goto(begin)

exten = 7,n(upper),NoOp(##### Lower #####)
exten = 7,n,Playback(/var/lib/xivo/sounds/playback/lower)
exten = 7,n,Goto(begin)

exten = 7,n(win),NoOp(##### Win #####)
exten = 7,n,Playback(/var/lib/xivo/sounds/playback/win)
exten = 7,n,Hangup()
Benoît Stahl
Project Manager