Openclose.agi: Difference between revisions
From KlavoWiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
The AGI script will | The AGI script will check on the status of the day as a call enters the system for reception. The caller is then passed to announcements or scripts based on the dialplan of asterisk and the results of the script. | ||
{| | |||
|================= | |||
|======================================== | |||
|- | |||
|Status | |||
|Description | |||
|- | |||
|================= | |||
|======================================== | |||
|- | |||
|open | |||
|Office is Open | |||
|- | |||
|closed | |||
|Office is Closed | |||
|- | |||
|holiday | |||
|Public Holiday Announcement | |||
|- | |||
|special | |||
|Specialised Announcement | |||
|- | |||
|stock | |||
|Office is Closed due to Stock Take | |||
|- | |||
|christmas | |||
|The office is closed over the Christmas break | |||
|} | |||
'''/var/lib/asterisk/agi-bin/openclose.agi''' | '''/var/lib/asterisk/agi-bin/openclose.agi''' | ||
Line 14: | Line 36: | ||
# Done by Alex Lopez (alex.lopez (at) O p s y s (dot) com) | # Done by Alex Lopez (alex.lopez (at) O p s y s (dot) com) | ||
# You may need to change the if/than logic depending on OS and Shell implementation. | # You may need to change the if/than logic depending on OS and Shell implementation. | ||
# | |||
# Modified by David Klaverstyn to have addational events: special, christmas, stock | |||
# A WEB page is avaiable so users can add/edit/delete entries. | |||
# Contact me for information on the how to obtain the WEB pages. | |||
# | # | ||
TODAY=`date +%d%m%y` | TODAY=`date +%d%m%y` | ||
Line 45: | Line 71: | ||
251209 ) STATUS=holiday;; # Christmas Day | 251209 ) STATUS=holiday;; # Christmas Day | ||
010110 ) STATUS=holiday;; # New Years Day | 010110 ) STATUS=holiday;; # New Years Day | ||
241011 ) STATUS=special;; # Office Closed due to an Emergency | |||
041111 ) STATUS=stock;; # Closed for Stock Take | |||
esac | esac | ||
# | # | ||
if test "$ | |||
if test "$DAY" == "Sat" -o \ | |||
"$DAY" == "Sun" | |||
then | |||
STATUS=closed | |||
fi | |||
# Place open days here that ignore Saturday or Sunday | |||
case "$TODAY" in | |||
221011 ) STATUS=testme;; # Just Testing | |||
231011 ) STATUS=special;; # Open Sunday | |||
esac | |||
if test "$TIMENOW" -lt "$OPEN" -o \ | |||
"$TIMENOW" -gt "$CLOSE" | |||
then | then | ||
STATUS= | STATUS=closed | ||
fi | fi | ||
# | # | ||
# | # | ||
Line 62: | Line 102: | ||
</pre> | </pre> | ||
Dialplan Configuration. | |||
<pre> | <pre> | ||
[reception] | [reception] | ||
exten => s,n,AGI(openclose.agi) | |||
exten => s,n,Goto(${result},1) | |||
exten => s,n,AGI(openclose.agi) | |||
exten => s,n, | |||
exten => | exten => open,1,Dial(${RECEPTION},20,t) | ||
exten => | exten => open,n,Background(busy) | ||
exten => open,n,Background(reception-busy) | |||
exten => open,n,Background(directory-or-message) | |||
exten => open,n,Waitexten | |||
exten => | exten => holiday,1,Background(thankyou) | ||
exten => | exten => holiday,n,Background(public-holiday) | ||
exten => | exten => holiday,n,Goto(t,1) | ||
exten => | exten => closed,1,Background(thankyou) | ||
exten => | exten => closed,n,Background(office-closed) | ||
exten => closed,n,Goto(t,1) | |||
exten => 1,1,Directory(default | exten => 1,1,Directory(default,internal) | ||
exten => i,1,Playback(invalid) | exten => i,1,Playback(invalid) | ||
exten => i,n,Goto( | exten => i,n,Goto(open,4) | ||
exten => t,1,Voicemail( | exten => t,1,Voicemail(1201@default,u) | ||
exten => t,n,HangUp | exten => t,n,HangUp | ||
</pre> | </pre> | ||
[[Category : Asterisk]] | [[Category : Asterisk]] |
Revision as of 13:54, 24 October 2011
The AGI script will check on the status of the day as a call enters the system for reception. The caller is then passed to announcements or scripts based on the dialplan of asterisk and the results of the script.
================= | ======================================== |
Status | Description |
================= | ======================================== |
open | Office is Open |
closed | Office is Closed |
holiday | Public Holiday Announcement |
special | Specialised Announcement |
stock | Office is Closed due to Stock Take |
christmas | The office is closed over the Christmas break |
/var/lib/asterisk/agi-bin/openclose.agi
#!/bin/sh # # Done by Alex Lopez (alex.lopez (at) O p s y s (dot) com) # You may need to change the if/than logic depending on OS and Shell implementation. # # Modified by David Klaverstyn to have addational events: special, christmas, stock # A WEB page is avaiable so users can add/edit/delete entries. # Contact me for information on the how to obtain the WEB pages. # TODAY=`date +%d%m%y` # DAY=`date +%a` HOUR=`date +%H` MINUTE=`date +%M` TIMENOW=$HOUR$MINUTE # OPEN=0900 CLOSE=1700 # # STATUS=closed # case "$TODAY" in 250408 ) STATUS=holiday;; # Anzac Day 050508 ) STATUS=holiday;; # Labour Day 090608 ) STATUS=holiday;; # Queens Birthday 130808 ) STATUS=holiday;; # Show Day 251208 ) STATUS=holiday;; # Christmas Day 261208 ) STATUS=holiday;; # Boxing Day 010109 ) STATUS=holiday;; # New Years Day 260109 ) STATUS=holiday;; # Australia Day 100409 ) STATUS=holiday;; # Good Friday 130409 ) STATUS=holiday;; # Easter Monday 250409 ) STATUS=holiday;; # Anzac Day 040509 ) STATUS=holiday;; # Labour Day 080609 ) STATUS=holiday;; # Queens Birthday 120809 ) STATUS=holiday;; # Show Day 251209 ) STATUS=holiday;; # Christmas Day 010110 ) STATUS=holiday;; # New Years Day 241011 ) STATUS=special;; # Office Closed due to an Emergency 041111 ) STATUS=stock;; # Closed for Stock Take esac # if test "$DAY" == "Sat" -o \ "$DAY" == "Sun" then STATUS=closed fi # Place open days here that ignore Saturday or Sunday case "$TODAY" in 221011 ) STATUS=testme;; # Just Testing 231011 ) STATUS=special;; # Open Sunday esac if test "$TIMENOW" -lt "$OPEN" -o \ "$TIMENOW" -gt "$CLOSE" then STATUS=closed fi # # echo "SET VARIABLE status $STATUS" echo "SET VARIABLE open $OPEN" echo "SET VARIABLE close $CLOSE"
Dialplan Configuration.
[reception] exten => s,n,AGI(openclose.agi) exten => s,n,Goto(${result},1) exten => open,1,Dial(${RECEPTION},20,t) exten => open,n,Background(busy) exten => open,n,Background(reception-busy) exten => open,n,Background(directory-or-message) exten => open,n,Waitexten exten => holiday,1,Background(thankyou) exten => holiday,n,Background(public-holiday) exten => holiday,n,Goto(t,1) exten => closed,1,Background(thankyou) exten => closed,n,Background(office-closed) exten => closed,n,Goto(t,1) exten => 1,1,Directory(default,internal) exten => i,1,Playback(invalid) exten => i,n,Goto(open,4) exten => t,1,Voicemail(1201@default,u) exten => t,n,HangUp