Storage and Recording
In this guide, you will learn how to set up storage and recording through the FlexML endpoint. The FlexML endpoint can be configured to save recordings. Recordings are integrated with the Storage API system. A container holds files, which are created automatically by the system when a recording is completed.
I. Configure Container
In this section, we will configure a container. This container will store files for recordings made through our FlexML instructions.
Click the Storage menu. Click Containers.
Click Add New Container.
Enter a name for the new container. This is a friendly name that is used for internal reference.
Enter integer values for Quota Bytes and Quota Files. Note that the quota sizes should be large enough to accomodate the size and amount of files that you require.
Click Add Container when finished.
Click the newly created container to see details. We will use the Container SID in the next step.
Now that we have created a container, we can store recordings. We can assign a container two ways—in our FlexML instructions as a supported attribute and to the FlexML endpoint. First, we will look at assigning the container to the Record
verb in our FlexML instructions.
II. FlexML for Recordings
In this section, we will set up recording for calls using FlexML. Refer to the FlexML Endpoint quick start guide for instructions to create a simple FlexML application. This application has three components—Python server and routing, ngrok tunnel to expose our localhost to the public Internet, and FlexML instructions.
After setting up a basic application, we will serve the following FlexML from one of the routes. All of our code is nested within code tags. The Record
verb is where we assign settings to the recording method. The containerSid
is the secure ID for the container that we created in the previous section, Configure Container. Refer to the FlexML API Reference for a comprehensive list of supported attributes.
<Response>
<Say>Thank you for calling. Please leave a message. </Say>
<Record containerSid="8d53344a-f312-40f8-93f5-bfba3f790b63" callbackUrl="/path/to/handler"></Record>
</Response>
In this example, the caller will hear the message between the Say
tags, and then the recording will start. The Record
verb can be customized with supported attributes, like the following:
action
is another set of FlexML instructions that will be requested after the recording has finished. Adding an action supporting attribute means that any verbs after the current verb will not run.callbackUrl
will provide data about a recording after it has ended.integerKey1
,integerKey2
,stringKey1
,stringKey2
can be used to set any meaningful data that you would like. This data can be used later for reference or filtering.playBeep
will play a beep noise before a recording begins.recordSession
can be used to record an entire session in the background.
For a full list of supported attributes for the Record
verb, refer to the FlexML API Reference.
Once the call is complete, the system will make a request to the callbackUrl
and send back the following object.
{
"AccountSid": "",
"ApiVersion": "2.0",
"CallerName": "",
"CallSid": "c996365e4043dc1d7c33a6f2829f9983",
"CallStatus": "",
"OriginalFrom": "19093189029",
"OriginalTo": "19093189029",
"Direction": "outbound-api",
"From": "19093189029",
"RecordingDuration": 10,
"RecordingFileSid": "7140cb0a-76a4-49fa-99a8-31ab00b71bd3",
"RecordingStatus": "completed",
"RecordingUrl": "https://storage.carrierx.com/f/7140cb0a-76a4-49fa-99a8-31ab00b71bd3",
"To": "19093189029"
}
The RecordingUrl
value has a link to the recording. You can also use the RecordingFileSid
to access the recording using the Storage API.
III. Assign Container
Rather than assign the containerSid
as a supported attribute in the FlexML itself, you can also assign a container to an endpoint. This way, all recordings will be saved to that container unless the container secure ID is overridden within the FlexML.
Navigate to the Configure menu, click Endpoints and select the endpoint you want to associate a container with. Click the Application: FlexML tab.
Click Edit.
Select the container you want to associate with the endpoint from the Default Container dropdown menu.
Click Save.
This container will store all of the files for this FlexML endpoint. A container can also be assigned to a FlexML endpoint programmatically. The container_sid
is passed in the properties
object. Refer to the Endpoints section of the Core API Reference for more information. The container_sid
can be assigned when the endpoint is first created, or later through a PATCH
or PUT
request.
IV. Next Steps
You have configured storage and recording with FlexML! For more information, refer to the FlexML API Reference.
If you would like to review the steps to configuring the FlexML endpoint, refer to the video tutorial.