Out-of-business greeting with FreeSWITCH

After I got my US number at Callcentric, I got several wrong calls in the following days. The calls were quite late at night, and most of them dropped after few seconds, before I could take up the handset. And another ring around 3am was really long and loud, and it dropped anyway before I could come up and pick the call.

First, I needed to record my own greeting. In “default” dialplan, I added a new extension. It takes a recording and plays it back :

  <!-- 7396: Record a greeting -->
  <extension name="app_7396">
    <condition field="destination_number" expression="^7396$">
      <action application="answer"/>
      <action application="sleep" data="500"/>
      <action application="playback" data="tone_stream://%(100,100,1400,2060,2450,2600)"/>
      <action application="set" data="playback_terminators=#"/>
      <action application="set" data="record_waste_resources=true"/>
      <action application="set" 
              data="recfilename=$${base_dir}/recordings/greeting_${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/>
      <action application="record" data="${recfilename}"/>
      <action application="sleep" data="700"/>
      <action application="playback" data="tone_stream://%(100,100,1400,2060,2450,2600)"/>
      <action application="playback" data="${recfilename}"/>
      <action application="hangup"/>
    </condition>
  </extension>

As I’m using a Gigaset 610IP handset with G722 codec, the produced recording had 16KHz sampling rate, and needed to be resampled, because inbound external calls are G711 only:

sox recordings/greeting_2013-08-17-11-46-35.wav sounds/dvop/8000/ssinyagin_oob.wav rate 8000

Then my extension in “public” dialplan is modified to play the greeting unless the call is between 7am and 11pm. It also plays MOH for 5 seconds before bridging the call, and continues playing MOH while ringing my phone.  This gives the mistaken caller another chance to realize that something is wrong and drop the call.

  <extension name="pub_ssinyagin">
    <condition field="destination_number" expression="^ssinyagin$" break="on-false">
      <action application="set" data="timezone=Europe/Zurich" inline="true"/> 
    </condition>

    <!-- 7:00 - 23:00 -->
    <condition minute-of-day="420-1000" break="on-true">
      <action application="answer"/>
      <action application="set" data="playback_timeout_sec=5"/>
      <action application="playback" data="$${hold_music}"/>
      <action application="set" data="ringback=$${hold_music}"/>
      <action application="transfer" data="7110 XML default"/>
    </condition>

    <condition>
      <action application="answer"/>
      <action application="sleep" data="1000"/>
      <action application="playback" data="$${sounds_dir}/dvop/ssinyagin_oob.wav"/>
      <action application="hangup"/>
    </condition>
  </extension>
Advertisements

, ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: