Recording a call in FreeSWITCH

The FreeSWITCH wiki page explains the call recording in details, and I’m using the following extension in my dialplan. Whenever I prefix the destination number with “#”, the outgoing call is automatically recorded. It’s also easy to add an execution of a Lua (or Javascript)  script which would insert the file name into some sort of a database, and then a front-end application would be able to retrieve the file (I’m just using FileZilla for myself).

    <extension name="start_recorder">
      <condition field="destination_number" expression="^\#(\d+)$">
        <action application="set" data="RECORD_TITLE=Recording ${destination_number} ${caller_id_number} ${strftime(%Y-%m-%d %H:%M)}"/>
        <action application="set" data=""/>
        <action application="set" data="RECORD_DATE=${strftime(%Y-%m-%d %H:%M)}"/>
        <action application="set" data="RECORD_STEREO=true"/>
        <action application="set" data="media_bug_answer_req=true"/>
        <action application="record_session" data="$${base_dir}/recordings/${strftime(%Y-%m-%d-%H-%M-%S)}_$1_${caller_id_number}.mp3"/>
        <action application="transfer" data="$1 XML default"/>


  1. #1 by Prachi on February 7, 2013 - 5:16 am

    What if I make make calls through my code recursively, how to record them all?

    • #2 by txlab on February 7, 2013 - 5:35 am

      you need to execute the application “record_session” on all of them. In this example, you select the calls for recording. If you need it for all calls, then the configuration is even simpler.

  2. #3 by Prachi on February 7, 2013 - 6:59 am


  3. #4 by Nikhitha on March 5, 2013 - 6:04 am

    The above dialplan is unable to record the outgoing call..And can u tell me can i record the conversation on each legs in different files??Howz it possible..I’ve checked it in Asterisk using monitor command,And i knew that in freeswitch we use record_session to do that.I am able to record both the conversations of users in a single file.But i want each of them in seperate files

    • #5 by txlab on March 5, 2013 - 6:33 am

      the above dialplan is actually recording the outgoing calls if they are prepended with a #.

      you can use sox for splitting the audio file if needed.

  4. #6 by Nikhitha on March 7, 2013 - 12:48 pm

    Not using anything like sox.When the call has been established between two users,then each of their conversation should be recorded in 2 different files immediately after the call is hung up.

  5. #7 by Andy on October 13, 2013 - 6:12 am

    hi. I faced with strange situation.
    I use command record_session in js file.
    Here is 2 lines from this file

    rec_f_name = ‘/var/www/recordings/’+new_session.uuid+’_rbt.wav’;
    new_session.execute(“record_session”, rec_f_name);

    In the end i got wav file with correct size and correct length, but there is no audio inside. Just silence.
    When I use command session.recordFile i got file with audio. It’s ok. But new_session.execute(“record_session” doesn’t work properly.

    I tryed to reinstall freeswitch from latest git.
    I turned of firewall.
    I checked settings.

    I don’t have any idea at all.
    Thanks for your help!

    • #8 by Andy on October 13, 2013 - 9:07 am

      Issue solved. Firewall was the problem)

  6. #9 by Purple_winged on September 18, 2017 - 1:34 pm

    What is the possible dial-plan for playing the recorded files in freeswitch?
    I can play a one single file say suppose i got many files recorded how do i listen to all .wav files via dial plan??

    • #10 by txlab on September 18, 2017 - 2:03 pm

      the easiest way would be to write a script in Lua or Perl, so that it reads the files in the directory and instructs FreeSWITCH to play them.

      • #11 by Purple_winged on September 19, 2017 - 8:34 am

        Thank you much.! will follow up with the scripts

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: