Record the Entire Length of a Call

⌘K
  1. Home
  2. Programmable Voice
  3. How do I
  4. Record the Entire Length of a Call

Record the Entire Length of a Call

RecordConversation Method

The RecordConversation method allows you to pass in two routable resources and a filename, and it will record both sides of a call, placing the audio in the same file. This function is useful for when you want to record the duration of a call.

Please note that RecordConversation is a synchronous command, so if you try to run it from your main thread, it will block. Instead, you will need to call it from a separate thread, as shown in the example below:

public void RecordConversation()
{
    RecordResource = TelephonyServer.GetVoiceResource();
    RecordResource.MaximumTime = 6000; // You can set this to any arbitrarily high number. This allows a max recording of 6000 seconds or 1 hour.
    RecordResource.MaximumSilence = 6000;
    RecordResource.TerminationDigits = "";
    tc = RecordResource.RecordConverstation(filename, VoiceResource, ChannelResource); /* By recording the Channel resource and the voice resource that a channel resource is routed to, you record what the IVR plays to the user.
    Alternatively, if you need to record both legs of a call, you would pass in the ChannelResource of one leg of the call, and the ChannelResource of the second leg of the call.*/
}
 
public void RunScript()
{
    System.Theading.Thread recordThread = new System.Threading.Thread(RecordConversation);
    recordThread.Start();
}

Stop RecordConversation

To stop the RecordConversation, you will need to do something like the following once the call has terminated. A good place to put this is in your final block when you are cleaning up resources.

RecordResource.Stop()

Join Files Together with WaveAppend

Please note that if you need to transfer the call, you will need to start a new RecordConversation to manage that side of the recording. You can join the files together, by using the WaveAppend function in the TelephonyServer class:

telephonyServer.WaveAppend("file1.wav", "file2.wav");
Was this article helpful to you? No Yes 15

How can we help?