<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/en/2176/25/9/_/styles/combined.css?spaceKey=AST&forWysiwyg=true" type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://wiki.asterisk.org/wiki/display/AST/Calendaring+Dialplan+Examples">Calendaring Dialplan Examples</a></h2>
<h4>Page <b>edited</b> by <a href="https://wiki.asterisk.org/wiki/display/~gdraque">Gaston Draque</a>
</h4>
<div id="versionComment">
<b>Comment:</b>
Applied the 'same' extension<br />
</div>
<br/>
<h4>Changes (7)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >[incoming] <br>exten => 5555551212,1,Answer <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">exten => 5555551212,n,GotoIf(${CALENDAR_BUSY(officehours)}?closed:attendant,s,1) <br>exten => 5555551212,n(closed),Set(id=${CALENDAR_QUERY(office,${EPOCH},${EPOCH})}) <br>exten => 5555551212,n,Set(soundfile=${CALENDAR_QUERY_RESULT(${id},description)}) <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;"> same => n,GotoIf(${CALENDAR_BUSY(officehours)}?closed:attendant,s,1) <br> same => n(closed),Set(id=${CALENDAR_QUERY(office,${EPOCH},${EPOCH})}) <br> same => n,Set(soundfile=${CALENDAR_QUERY_RESULT(${id},description)}) <br></td></tr>
<tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">exten</span> <span class="diff-added-words"style="background-color: #dfd;">same</span> => <span class="diff-changed-words"><span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">5555551212,</span>n,Playback($[${ISNULL(soundfile)}</span> ? generic-closed :: ${soundfile}]) <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">exten => 5555551212,n,Hangup <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;"> same => n,Hangup <br></td></tr>
<tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >[calendar_event_notify] <br>exten => s,1,Answer <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">exten => s,n,Playback(you-have-a-meeting-at) <br>exten => s,n,SayUnixTime(${CALENDAR_EVENT(start)}) <br>exten => s,n,Hangup <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;"> same => n,Playback(you-have-a-meeting-at) <br> same => n,SayUnixTime(${CALENDAR_EVENT(start)}) <br> same => n,Hangup <br></td></tr>
<tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
</table>
</div> <h4>Full Content</h4>
<div class="notificationGreySide">
<h3><a name="CalendaringDialplanExamples-Officehours"></a>Office hours</h3>
<p>A common business PBX scenario is would be executing dialplan logic based on when the business is open and the phones staffed. If the business is closed for holidays, it is sometimes desirable to play a message to the caller stating why the business is closed. </p>
<p>The standard way to do this in asterisk has been doing a series of GotoIfTime statements or time-based include statements. Either way can be tedious and requires someone with access to edit asterisk config files. </p>
<p>With calendaring, the adminstrator only needs to set up a calendar that contains the various holidays or even recurring events specifying the office hours. A custom greeting filename could even be contained in the description field for playback. For example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">[incoming]
exten => 5555551212,1,Answer
same => n,GotoIf(${CALENDAR_BUSY(officehours)}?closed:attendant,s,1)
same => n(closed),Set(id=${CALENDAR_QUERY(office,${EPOCH},${EPOCH})})
same => n,Set(soundfile=${CALENDAR_QUERY_RESULT(${id},description)})
same => n,Playback($[${ISNULL(soundfile)} ? generic-closed :: ${soundfile}])
same => n,Hangup</pre>
</div></div>
<h3><a name="CalendaringDialplanExamples-Meetingreminders"></a>Meeting reminders</h3>
<p>One useful application of Asterisk Calendaring is the ability to execute dialplan logic based on an event notification. Most calendaring technologies allow a user to set an alarm for an event. If these alarms are set on a calendar that Asterisk is monitoring and the calendar is set up for event notification via calendar.conf, then Asterisk will execute notify the specified channel at the time of the alarm. If an overrided notification time is set with the autoreminder setting, then the notification would happen at that time instead. </p>
<p>The following example demonstrates the set up for a simple event notification that plays back a generic message followed by the time of the upcoming meeting. calendar.conf.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">[calendar_joe]
type = ical
url = https://example.com/home/jdoe/Calendar
user = jdoe
secret = mysecret
refresh = 15
timeframe = 600
autoreminder = 10
channel = SIP/joe
context = calendar_event_notify
extension = s
waittime = 30</pre>
</div></div>
<p>extensions.conf : </p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">[calendar_event_notify]
exten => s,1,Answer
same => n,Playback(you-have-a-meeting-at)
same => n,SayUnixTime(${CALENDAR_EVENT(start)})
same => n,Hangup</pre>
</div></div>
<h3><a name="CalendaringDialplanExamples-Writinganevent"></a>Writing an event</h3>
<p>Both CalDAV and Exchange calendar servers support creating new events. The following example demonstrates writing a log of a call to a calendar.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">[incoming]
exten => 6000,1,Set(start=${EPOCH})
exten => 6000,n,Dial(SIP/joe)
exten => h,1,Set(end=${EPOCH})
exten => h,n,Set(CALENDAR_WRITE(calendar_joe,summary,start,end)=Call from ${CALLERID(all)},${start},${end})</pre>
</div></div>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;" class="grey">
<a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
<span style="padding: 0px 5px;">|</span>
<a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
<a href="https://wiki.asterisk.org/wiki/display/AST/Calendaring+Dialplan+Examples">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=5243072&revisedVersion=2&originalVersion=1">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/Calendaring+Dialplan+Examples?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>