NAVIGATION
Home
Gallery
Java
Linux
Web
Scripts And Utilities
Mobile And Sms
Misc
Contact
pixelWIKI
Nabaz Tag




<<

Nab Asterisk

Asterisk AGI scripts, to record a message and have your Nabaz Tag play it back, with an announcement message. This script assumes that your web server is on the same server as Asterisk, and the target folder for the MP3s is writable by the Asterisk user

Other Nabaztag Scripts

The AGI script (goes in /var/lib/asterisk/agi-bin)

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
! /bin/sh
NAB_SN=0013d38451ce
NAB_TOKEN=1222518865
NAB_VOICE=UK-Mistermuggles
MP3_PATH=www.pixelseventy2.net/rabbit/voice


declare -a array
while read -e ARG && [ "$ARG" ] ; do
        array=(` echo $ARG | sed -e 's/://'`)
        export ${array[0]}=${array[1]}
done

echo "CID: $agi_callerid" >&2
echo "Encoding /tmp/bunny_${1}.wav" >&2
lame -b 64 -m m /tmp/bunny_${1}.wav /data/web/STATIC/default/rabbit/voice/bunny_${1}.mp3 >&2
curl "http://api.nabaztag.com/vl/FR/api.jsp?token=$NAB_TOKEN&sn=$NAB_SN&voice=$NAB_VOICE&tts=New+message+from+${agi_callerid:0:5}+${agi_callerid:5}" >/dev/null 1>&2
curl "http://api.nabaztag.com/vl/FR/api_stream.jsp?token=$NAB_TOKEN&sn=$NAB_SN&urlList=http%3A//${MP3_PATH}/bunny_${1}.mp3" > /dev/null 1>&2



extensions.conf
The voice prompts say:
bunny_intro - Please leave your message for the bunny to say, then press the # key.
bunny_confirm - To send the message, press 1. To re-record the message, press 2. To cancel, hang up.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
[nabaztag]
exten => s,1,noop(${CALLERID}) )
exten => s,n,Set(DT=${DATETIME})
exten => s,n,noop(${DT})
exten => s,n,Playback(/data/asterisk/sounds/custom/bunny_intro)
exten => s,n,record(/tmp/bunny_${DT}.wav)
exten -> s,n,Wait(1)
exten => s,n,Playback(/tmp/bunny_${DT})
exten => s,n,Wait(1)
exten => s,n,Background(/data/asterisk/sounds/custom/bunny_confirm)
exten => s,n,WaitExten(5)
exten => s,n,Hangup


exten => 1,1,AGI(bunny.sh|${DT})
exten => 1,n,hangup()

exten => 2,1,Goto(s,1)

exten => i,1,Playback(invalid)
exten => i,n,Goto(s,1)