Openclose.agi: Difference between revisions

From KlavoWiki
Jump to navigationJump to search
New page: The AGI script will information the caller if the office is: :open :closed :public holiday If the office is open the the recption phone will ring.<br> If the office is closed it will info...
 
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
The AGI script will information the caller if the office is:
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.
:open
{|
:closed
|=================
:public holiday
|========================================
|-
|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
|}


If the office is open the the recption phone will ring.<br>
= openclose script =
If the office is closed it will information the caller office is open between what hours and go to message bank.<br>
<pre>
If it is a public holiday user will be information office is closed because of a public holiday and go to message bank.<br>
#!/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.
#
# http://www.klaverstyn.com.au/david/wiki/index.php?title=Openclose.agi
 
TODAY=`date +%d%m%y`
 
DAY=`date +%a`
HOUR=`date +%H`
MINUTE=`date +%M`
TIMENOW=$HOUR$MINUTE


'''/var/lib/asterisk/agi-bin/openclose.agi'''
OPEN=0900
CLOSE=1700
 
STATUS=open
 
case "$TODAY" in
  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"
</pre>
 
= Dialplan Configuration =
<pre>
[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,PlayBack(thankyou)
exten => holiday,n,PlayBack(public-holiday)
exten => holiday,n,Goto(t,1)
 
exten => closed,1,PlayBack(thankyou)
exten => closed,n,PlayBack(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
</pre>
 
= Original openclose =
<pre>
<pre>
#!/bin/sh
#!/bin/sh
Line 25: Line 140:
#
#
case "$TODAY" in
case "$TODAY" in
  251206 ) STATUS=holiday;; # Christmas Day
  261206 ) STATUS=holiday;; # Boxing Day
  010107 ) STATUS=holiday;; # New Years
  260107 ) STATUS=holiday;; # Australia Day
  060407 ) STATUS=holiday;; # Good Friday
  090407 ) STATUS=holiday;; # Easter Monday
  250407 ) STATUS=holiday;; # Anzac Day
  110607 ) STATUS=holiday;; # Queens Birthday
  060807 ) STATUS=holiday;; # Bank Holiday
  011007 ) STATUS=holiday;; # Labour Day
  251207 ) STATUS=holiday;; # Christmas Day
  261207 ) STATUS=holiday;; # Boxing day
  010108 ) STATUS=holiday;; # New Years Day
  260108 ) STATUS=holiday;; # Australia Day
  210308 ) STATUS=holiday;; # Good Friday
  240308 ) STATUS=holiday;; # Easter Monday
   250408 ) STATUS=holiday;; # Anzac Day
   250408 ) STATUS=holiday;; # Anzac Day
  050508 ) STATUS=holiday;; # Labour Day
   090608 ) STATUS=holiday;; # Queens Birthday
   090608 ) STATUS=holiday;; # Queens Birthday
   130808 ) STATUS=holiday;; # Show Day
   061008 ) STATUS=holiday;; # Labour Day
   251208 ) STATUS=holiday;; # Christmas Day
   251208 ) STATUS=holiday;; # Christmas Day
   261208 ) STATUS=holiday;; # Boxing 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
esac
esac
#
#
Line 47: Line 167:
     "$DAY" != "Sun" -a \
     "$DAY" != "Sun" -a \
     "$TIMENOW" -gt "0900" -a \
     "$TIMENOW" -gt "0900" -a \
     "$TIMENOW" -lt "1700"
     "$TIMENOW" -lt "1730"
then
then
   STATUS=open
   STATUS=open
Line 53: Line 173:
#
#
#
#
echo "SET VARIABLE status $STATUS"  
echo "SET VARIABLE status $STATUS"
</pre>
 
<pre>
[reception]
exten => s,1,Set(TIMEOUT(digit)=2)
exten => s,n,Set(TIMEOUT(response)=3)
exten => s,n,AGI(openclose.agi) ; check whether the office is open/closed/holiday by running external script
exten => s,n,GotoIf($[${STATUS} = open]?open:checkholiday)
 
exten => s,n(checkholiday),Ringing ; run if not open
exten => s,n,Wait(2)
exten => s,n,Answer
exten => s,n,Wait(1)
exten => s,n,Background(thankyou) ; Welcome Message
exten => s,n,GotoIf($[${STATUS} = holiday]?holiday:closed) ; check if office is closed/holiday
exten => s,n,Hangup
 
exten => s,n(holiday),Background(public-holiday) ; run if office is on holiday
exten => s,n,Goto(end)
 
exten => s,n(closed),Background(office-closed) ; run if office is closed
exten => s,n,Goto(end)
 
exten => s,n(open),Dial(${RECEPTION},20,t) ; run if office is open, ring reception and kitchen only.
exten => s,n(CheckMessage),Background(busy)
exten => s,n,Background(intergraph/reception-busy)
 
exten => s,n(end),Background(directory-or-message) ; ask user if they want to query directory
exten => s,n,Waitexten
 
exten => 1,1,Directory(default|internal) ; voicemail.conf context | context to pass numbers to (4 digit ext numbers)
 
exten => i,1,Playback(invalid)
exten => i,n,Goto(s,end)
 
exten => t,1,Voicemail(u1201@default)
exten => t,n,HangUp
</pre>
</pre>


[[Category : Asterisk]]
[[Category : Asterisk]]

Latest revision as of 22:05, 25 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

openclose script

#!/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.
#
# http://www.klaverstyn.com.au/david/wiki/index.php?title=Openclose.agi

TODAY=`date +%d%m%y`

DAY=`date +%a`
HOUR=`date +%H`
MINUTE=`date +%M`
TIMENOW=$HOUR$MINUTE

OPEN=0900
CLOSE=1700

STATUS=open

case "$TODAY" in
  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,PlayBack(thankyou)
exten => holiday,n,PlayBack(public-holiday)
exten => holiday,n,Goto(t,1)

exten => closed,1,PlayBack(thankyou)
exten => closed,n,PlayBack(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

Original openclose

#!/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.
#
TODAY=`date +%d%m%y`
#
DAY=`date +%a`
HOUR=`date +%H`
MINUTE=`date +%M`
TIMENOW=$HOUR$MINUTE
#
STATUS=closed
#
case "$TODAY" in
  251206 ) STATUS=holiday;; # Christmas Day
  261206 ) STATUS=holiday;; # Boxing Day
  010107 ) STATUS=holiday;; # New Years
  260107 ) STATUS=holiday;; # Australia Day
  060407 ) STATUS=holiday;; # Good Friday
  090407 ) STATUS=holiday;; # Easter Monday
  250407 ) STATUS=holiday;; # Anzac Day
  110607 ) STATUS=holiday;; # Queens Birthday
  060807 ) STATUS=holiday;; # Bank Holiday
  011007 ) STATUS=holiday;; # Labour Day
  251207 ) STATUS=holiday;; # Christmas Day
  261207 ) STATUS=holiday;; # Boxing day
  010108 ) STATUS=holiday;; # New Years Day
  260108 ) STATUS=holiday;; # Australia Day
  210308 ) STATUS=holiday;; # Good Friday
  240308 ) STATUS=holiday;; # Easter Monday
  250408 ) STATUS=holiday;; # Anzac Day
  090608 ) STATUS=holiday;; # Queens Birthday
  061008 ) STATUS=holiday;; # Labour Day
  251208 ) STATUS=holiday;; # Christmas Day
  261208 ) STATUS=holiday;; # Boxing Day
esac
#
if  test "$STATUS" != "holiday" -a \
    "$DAY" != "Sat" -a \
    "$DAY" != "Sun" -a \
    "$TIMENOW" -gt "0900" -a \
    "$TIMENOW" -lt "1730"
then
  STATUS=open
fi
#
#
echo "SET VARIABLE status $STATUS"