Telephone system:Closing announcement

From Hackerspace ACKspace
Jump to: navigation, search

This collection of scripts was used to broadcast (closing) announcements using cron jobs

While this script is not in use anymore, since we're a 24/7 space now, it still is fun to trigger announcements using cron jobs

it used to trigger on 9:30PM on weekdays, and 4:30PM on saturday. At first I tried to retrigger the events in the dialplan for the next occurrence, but cron jobs are way more reliable (and easier)

crontab for freeswitch user

30  21  *   *   1-5 /usr/local/freeswitch/bin/fs_cli -x "originate loopback/1399 closure"
30  16  *   *   6   /usr/local/freeswitch/bin/fs_cli -x "originate loopback/1399 closure"


This script takes the dialstring of all members withing call group 'intercom' and puts them as conference-auto-out-call separately. After that, the conference is started with the sound extension, and all parsed extensions will be called automatically (assuming that extension has auto-answer for that line) When the sound extension is done and hangs up, everyone is kicked out of the conference.

if (session.ready())

    console_log(4, "building-wide paging\n");

    var pageGroup = session.getVariable("pageGroup");
    var arrPageGroup = pageGroup.split( ":_:" );
    for ( var idx = 0; idx < arrPageGroup.length; idx++ )
        var user = arrPageGroup[ idx ];
        user = user.replace( /\n/g, "" );
        user = user.replace( /\[[^\]]*\](.*)/g, "$1" );
        session.execute("conference_set_auto_outcall", user);


The announcement consists of two parts: triggering a group-intercom and executing a 'closure' extension which played the appropriate sounds

<extension name="group_page">
    <condition field="destination_number" expression="^(1399)$">
        <action application="set" data="api_hangup_hook=conference 412 kick all"/>
        <action application="answer"/>
        <action application="export" data="sip_invite_params=intercom=true"/>
        <action application="export" data="sip_auto_answer=true"/>
        <action application="set" data="conference_auto_outcall_caller_id_name=$${effective_caller_id_name}"/>
        <action application="set" data="conference_auto_outcall_caller_id_number=$${effective_caller_id_number}"/>
        <action application="set" data="conference_auto_outcall_timeout=5"/>
        <action application="set" data="conference_auto_outcall_flags=mute"/>
        <action application="javascript" data="paging.js"/>
        <action application="set" data="res=${sched_api +1 none conference 412 play tone_stream://path=${base_dir}/conf/beep.ttml}"/>
        <action application="conference" data="412@intercom"/>
        <action application="conference" data="412 kick all"/>

<extension name="closing announcement">
    <condition field="destination_number" expression="^closure|1398$" break="on-false">
        <action application="set" data="language=nl"/>
        <action application="answer"/>
        <action application="sleep" data="2000"/>
        <action application="set_audio_level" data="write -2"/>
        <action application="playback" data="../../../stationsbel.mp3"/>
        <action application="set_audio_level" data="write 0"/>
        <action application="playback" data="../../../nl/nl/xander/ivr/sluiten.wav"/>
        <action application="sleep" data="1000"/>
        <action application="set_audio_level" data="write -2"/>
        <action application="playback" data="../../../game_over.mp3"/>