Skip to main content

Recording Calls

In Making and Receiving Phone Calls we learned how to use XML bins to define what should happen when a call is received by one of your SignalWire numbers. In that case, we just played some audio. In this article, instead, we will use the same technique to record the audio of the call.

XML for Call Recording

We are going to define the instructions for recording the call in an XML bin hosted on SignalWire. To create an XML bin, go to the "LaML" section in your SignalWire space, then click on "Bins".

In the LaML page of a SignalWire Space, the Bins tab is circled in red.

To create a new XML bin, click the blue button in the LaML section of your SignalWire Space.

Create a new bin, and paste the following XML in it:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Record />
</Response>

We used the <Record> verb to start the recording, which will then be available from your SignalWire Space under the LaML section.

The <Record> verb accepts a large number of optional attributes which can be used to notify the state of a recording to an external URL, to define a set of keys that will stop the recording, to enable voice transcription, and much more. Check out the technical documentation.

Assigning the Bin to a SignalWire Phone Number

The final step is to configure one of your SignalWire phone numbers to answer calls using the XML bin we just created. You can do that from the "Phone Numbers" section:

In the Phone Numbers page of a SignalWire Space, a phone number edit pane is shown. 'Accept Incoming Calls' is set to 'Voice Calls'. 'Handle Calls Using' is set to 'LaML Webhooks'. 'When a Call Comes In' is set to the desired XML Bin URL.

To configure your number to handle incoming calls with an XML bin, set "Handle calls using" to "LaML Webhooks", then specify the URL of the XML bin.

Refer to Making and Receiving Phone Calls for more information about this step.

Conclusion

You are now ready to test the call recording bin.

XML bins offer a quick and easy way to get started with common use cases. If you are an advanced developer, or you need more flexibility and real-time control on your calls, you may be interested in our guide about how to make and receive calls in Node.js.