<br><br><div class="gmail_quote">On Mon, May 28, 2012 at 2:51 AM, Sherif Omran <span dir="ltr"><<a href="mailto:sherifomran2000@yahoo.com" target="_blank">sherifomran2000@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font:inherit" valign="top">Hi guys,<br><br>Any body knows how to schedule calls depending on some internal variables. Such as at 8pm, users with voice mail not yet delivered receive a call.<br>
<br>Thanks<span class="HOEnZb"><font color="#888888"><br>S.<br></font></span></td></tr></tbody></table><br></blockquote><br></div>You can also use the sched_api API command:<br><a href="http://wiki.freeswitch.org/wiki/Mod_commands#sched_api">http://wiki.freeswitch.org/wiki/Mod_commands#sched_api</a><br>
<br>You'll need to convert to epoch seconds or use an offset from the current time. For example:<br><span style="font-family:courier new,monospace">sched_api +3600 foo originate user/1000 &park</span><br><br>Will call user 1000 in 3600 seconds (1 hour) and park the call. (Obviously you'll send the call somewhere other than 'park')<br>
<br>If you want an absolute time then you'll need to convert to epoch seconds. Use 'strepoch' to convert a date/time string into epoch seconds. The 'strftime' displays the current date/time in the proper format:<br>
<br><span style="font-family:courier new,monospace">freeswitch@internal> strftime</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">2012-05-29 12:40:22</span><br style="font-family:courier new,monospace">
<br>By itself, 'strepoch' displays the current date/time in epoch seconds:<br><span style="font-family:courier new,monospace">freeswitch@internal> strepoch</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">1338320491</span><br style="font-family:courier new,monospace">
<br>To get a specific date/time just feed it as an argument. 6PM tonight is this:<br><span style="font-family:courier new,monospace">freeswitch@internal> strepoch 2012-05-29 18:00:00</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">1338339600</span><br style="font-family:courier new,monospace"><br>Feed that into your sched_api:<br><span style="font-family:courier new,monospace">freeswitch@internal> sched_api 1338339600 foo originate user/1001 &park</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">+OK Added: 10</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">2012-05-29 12:44:01.405063 [DEBUG] switch_scheduler.c:214 Added task 10 sched_api_function (foo) to run at 1338339600</span><br style="font-family:courier new,monospace">
<br>And verify that task 10 is there:<br><span style="font-family:courier new,monospace">freeswitch@internal> show tasks</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">task_id,task_desc,task_group,task_sql_manager,hostname</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">1,zrtp_cache_save,core,0,fs.debian</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">2,heartbeat,core,0,fs.debian</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">3,check_ip,core,0,fs.debian</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">4,limit_hash_cleanup,mod_hash,0,fs.debian</span><br style="font-family:courier new,monospace">
<b><span style="font-family:courier new,monospace">10,sched_api_function,foo,0,fs.debian</span></b><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">5 total.</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">freeswitch@internal></span><br style="font-family:courier new,monospace"><br>And use 'sched_del' to remove it if you no longer need it:<br>
<span style="font-family:courier new,monospace">freeswitch@internal> sched_del 10</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">+OK Deleted: 1</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">2012-05-29 12:46:22.845040 [DEBUG] switch_scheduler.c:138 Deleting task 10 sched_api_function (foo)</span><br style="font-family:courier new,monospace">
<br>Bonus feature: use 'expand' API to roll it all into a single command:<br><span style="font-family:courier new,monospace">freeswitch@internal> expand sched_api ${strepoch 2012-05-29 18:00:00} foo originate user/1001 &park</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">+OK Added: 11</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">2012-05-29 12:48:11.785045 [DEBUG] switch_scheduler.c:214 Added task 11 sched_api_function (foo) to run at 1338339600</span><br style="font-family:courier new,monospace">
<br><br>Please tinker away and let us know what you decide to do. You'll need something to talk to the FreeSWITCH event socket to send all these commands. Any ESL (event socket library) compatible language is a good choice. We have people who use Perl, Python, PHP, and Ruby all successfully, so any of those is a good choice.<br>
<br>-MC<br>