login | register
Wed 20 of Aug, 2008 [11:46 UTC]

voip-info.org

Discuss [3] History

Asterisk tips wiki

Created by: taggy,Last modification on Fri 03 of Dec, 2004 [18:03 UTC]

Asterisk Audio wiki


This is the product of me trying to get a better understanding of the dialplan. Use at you own risk.
It will give you a wiki, that your users can add recordings to, delete them again, append something to them and all.
Be careful. This system has 6 ext (maximum-file-length - 1) possible entries, so it might very well take up all your
harddisk-space.


Files you will need:

in /var/lib/asterisk/sounds/wiki/:

help/options.gsm - "The following subentries exist"
help/noopts.gsm - "No subentries were found"
help/8-append.gsm - "Press 8 to append something to the current file"
help/9-delete.gsm - "Press 9 to delete the current file"
help/7-modify.gsm - "Press 7 to modify the current file"
help/0-goup.gsm - "Press 0 to go up one level"
help/or.gsm - "or"
0.gsm - Your Main wiki-File ("Hello, this is our wiki.. press (*) for help, or choose a subentry by pressing (1)-(6)")
ask_overwrite.gsm - "Are you sure you want to overwrite this file?"
ask_delete.gsm - "Are you sure you want to delete this file?"
ask_append.gsm - "Are you sure you want to append to this file?"

in /var/lib/asterisk/system/:

fexists.sh

#!/bin/bash

for file in $1; do
if [ -f $file ] ; then
       exit;
else
       exit 1;
fi
done


wikiconcat.sh

#!/bin/bash
mv $1 $1temp.gsm
sox $1temp.gsm $2 $1
rm $1temp.gsm
rm $2


The dialplan:

[wiki]
exten => s,1,Answer

####################################
# initialise the digitstack with 0 #
####################################
exten => s,2,SetVar(digitstack=0)

####################################################################
# check if the file corresponding to the current digitstack exists #
####################################################################
exten => s,3,System(/var/lib/asterisk/system/fexists.sh /var/lib/asterisk/sounds/wiki/${digitstack}.gsm)
exten => s,4,Noop(s3)

####################
# if yes, playback #
####################
exten => s,5,Background(wiki/${digitstack})
exten => s,6,Goto(wikioptions,s,1)

##################
# if not, record #
##################
exten => s,104,Record(/var/lib/asterisk/sounds/wiki/${digitstack}:gsm)
exten => s,105,Goto(s,3)

################################################################################################
# if (0) is dialed, delete last digit from the digitstack, thus going up one level in the menu #
################################################################################################
exten => _0,1,SetVar(digitstack=${digitstack:0:$[${LEN(${digitstack})} - 1]})
exten => _0,2,GotoIf($[${LEN(${digitstack})} = 0]?s,2)
exten => _0,3,Goto(s,3)

#########################################################################################
# if (7) is dialed, ask for confirmation, then record new file, overwriting the old one #
#########################################################################################
exten => _7,1,SetVar(pressed=7)
exten => _7,2,SetVar(ask=overwrite)
exten => _7,3,SetVar(goyes=6)
exten => _7,4,SetVar(gono=7)
exten => _7,5,Goto(wikikeepdel,s,1)
exten => _7,6,Record(/var/lib/asterisk/sounds/wiki/${digitstack}:gsm)
exten => _7,7,Goto(s,3)

####################################################################################
# if (8) is dialed, record, then ask for confirmation, then append to current file #
####################################################################################
exten => _8,1,Record(/var/lib/asterisk/sounds/wiki/${digitstack}-temp:gsm)
exten => _8,2,SetVar(pressed=8)
exten => _8,3,SetVar(ask=append)
exten => _8,4,SetVar(goyes=7)
exten => _8,5,SetVar(gono=9)
exten => _8,6,Goto(wikikeepdel,s,1)
exten => _8,7,System(/var/lib/asterisk/system/wikiconcat.sh /var/lib/asterisk/sounds/wiki/${digitstack}.gsm /var/lib/asterisk/sounds/wiki/${digitstack}-temp.gsm)
exten => _8,8,Goto(s,3)
exten => _8,9,System(rm /var/lib/asterisk/sounds/wiki/${digitstack}-temp.gsm)
exten => _8,10,Goto(s,3)

#######################################################
# if (9) is dialed, ask for confirmation, then delete #
#######################################################
exten => _9,1,SetVar(pressed=9)
exten => _9,2,SetVar(ask=delete)
exten => _9,3,SetVar(goyes=6)
exten => _9,4,SetVar(gono=9)
exten => _9,5,Goto(wikikeepdel,s,1)
exten => _9,6,System(rm /var/lib/asterisk/sounds/wiki/${digitstack}*.gsm)
exten => _9,7,SetVar(digitstack=${digitstack:0:$[${LEN(${digitstack})} - 1]})
exten => _9,8,GotoIf($[${LEN(${digitstack})} = 0]?s,2)
exten => _9,9,Goto(s,3)

###################################
# playback help if (*) is pressed #
###################################

exten => _*,1,Playback(wiki/help/0-goup)
exten => _*,2,Playback(wiki/help/7-modify)
exten => _*,3,Playback(wiki/help/8-append)
exten => _*,4,Playback(wiki/help/9-delete)
exten => _*,5,Goto(wiki,s,3)

##########################################################
# for any other number (1)-(6), put it on the digitstack #
##########################################################
include => wikigrabnum


[wikigrabnum]
###################################################
# Grab dialed number and put it on the digitstack #
###################################################
exten => _X,1,SetVar(digitstack=${digitstack}${EXTEN})
exten => _X,2,Noop(X1)
exten => _X,3,Goto(wiki,s,3)

[wikikeepdel]
##################
# Are you sure ? #
##################
exten => s,1,Background(wiki/ask_${ask})
exten => s,2,Goto(s,1)

exten => _1,1,Goto(wiki,${pressed},${goyes})
exten => _2,1,Goto(wiki,${pressed},${gono})

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

[wikioptions]
################################################
# List existing entries in the current submenu #
################################################
exten => s,1,SetVar(option=0)
exten => s,2,SetVar(options=0)
exten => s,3,Playback(wiki/help/options)
exten => s,4,SetVar(option=$[${option} + 1])
exten => s,5,System(/var/lib/asterisk/system/fexists.sh /var/lib/asterisk/sounds/wiki/${digitstack}${option}.gsm)
exten => s,6,NoOp ;Playback(wiki/help/or)
exten => s,7,SayDigits(${option})
exten => s,8,SetVar(options=1)
exten => s,9,GotoIf($[ "${option}" = "7" ]?s,10:s,4)
exten => s,10,GotoIf($[ "${options}" = "0" ]?s,11:wiki,s,3)
exten => s,11,Playback(wiki/help/noopts)
exten => s,12,Goto(wiki,s,3)

exten => s,106,GotoIf($[ "${option}" = "7" ]?s,10:s,4)



the last thing you need is an entry in your dial-in context, that does a "Goto(wiki,s,1)"


i hope there're no tikiwiki-formatting-related errors in this.. seems sometimes it's a bad thing to use some common characters for formating... or i'm too stupid to find out how this works... so if you find errors here, feel free to correct them... ;-)


Comments

Comments Filter
222

333

by taggy, Thursday 22 of November, 2007 [19:41:06 UTC]
wow.. just found this posting.. and found that it got a comment years after it was initialy posted... by now, what i've written then looks realy realy ugly.. uOh.. :-)

well, it was never ment to be integrated with a wiki engine. but if you want to try integrate it... well, have fun.. :-)
222

333

by taggy, Thursday 22 of November, 2007 [19:41:05 UTC]
wow.. just found this posting.. and found that it got a comment years after it was initialy posted... by now, what i've written then looks realy realy ugly.. uOh.. :-)

well, it was never ment to be integrated with a wiki engine. but if you want to try integrate it... well, have fun.. :-)
222

333Sounds wonderful!

by voipnovice, Monday 05 of February, 2007 [11:53:16 UTC]
The audio wiki concept sounds wonderful. Thanks to taggy. However, The article does not make it clear whether this should be integrated with some wiki engine or can run independently without the front end on the net?

It would be great if there is something where a visitor to the web can click a button to update. Any ideas how to accomplish? Thanks!

Taggy's contacts would be appreciated. Thanks!