[Freeswitch-users] how to schedule calls

Michael Collins msc at freeswitch.org
Tue May 29 23:35:33 MSD 2012

On Mon, May 28, 2012 at 2:51 AM, Sherif Omran <sherifomran2000 at yahoo.com>wrote:

> Hi guys,
> 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.
> Thanks
> S.
You can also use the sched_api API command:

You'll need to convert to epoch seconds or use an offset from the current
time. For example:
sched_api +3600 foo originate user/1000 &park

Will call user 1000 in 3600 seconds (1 hour) and park the call. (Obviously
you'll send the call somewhere other than 'park')

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:

freeswitch at internal> strftime
2012-05-29 12:40:22

By itself, 'strepoch' displays the current date/time in epoch seconds:
freeswitch at internal> strepoch

To get a specific date/time just feed it as an argument. 6PM tonight is
freeswitch at internal> strepoch 2012-05-29 18:00:00

Feed that into your sched_api:
freeswitch at internal> sched_api 1338339600 foo originate user/1001 &park
+OK Added: 10

2012-05-29 12:44:01.405063 [DEBUG] switch_scheduler.c:214 Added task 10
sched_api_function (foo) to run at 1338339600

And verify that task 10 is there:
freeswitch at internal> show tasks

5 total.

freeswitch at internal>

And use 'sched_del' to remove it if you no longer need it:
freeswitch at internal> sched_del 10
+OK Deleted: 1

2012-05-29 12:46:22.845040 [DEBUG] switch_scheduler.c:138 Deleting task 10
sched_api_function (foo)

Bonus feature: use 'expand' API to roll it all into a single command:
freeswitch at internal> expand sched_api ${strepoch 2012-05-29 18:00:00} foo
originate user/1001 &park
+OK Added: 11

2012-05-29 12:48:11.785045 [DEBUG] switch_scheduler.c:214 Added task 11
sched_api_function (foo) to run at 1338339600

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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20120529/642ff640/attachment-0001.html 

Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list