Storage and Recording with FlexML

A detailed guide to using storage and recording with the FlexML endpoint.

Overview


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.



Configure a Container


In this section, we will configure a container. This container will store files for recordings made through our FlexML instructions.

1. Click on the Storage menu. Click Container .



2. Click Add New Container .



3. Enter a name for the new container. This is a friendly name that is used for internal reference.



4. 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.



5. Click Add Container when finished.



6. Click on 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.



Write FlexML for Recordings


In this section, we will set up recording for calls using FlexML. Refer to the FlexML 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. The way that our sample application is built is just an example. It is not necessary to build your application with Python or to use ngrok.

After setting up a basic application, we will serve the following FlexML from one of the routes. All of our code is nested within Response 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 a Container. Refer to the FlexML Reference Guide for a comprehensive list of supported attributes.

<Response>
  <Say>Thank you for calling. Please leave a message. </Say>
  <Record containerSid="c53a470a-be20-4633-913f-80cfd3edb254" 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:

For a full list of supported attributes for the Record verb, refer to the FlexML Reference Guide .


Once the call is complete, the system will make a request to the callbackUrl and send back the following object. The RecordingUrl value has a link to the recording. You can also use the RecordingFileSid to access the recording using the Storage API .

{
  "OriginalTo": "19093189029", 
  "AccountSid": "", 
  "RecordingFileSid": "7140cb0a-76a4-49fa-99a8-31ab00b71bd3", 
  "OriginalFrom": "19093189029", 
  "Direction": "outbound-api", 
  "RecordingUrl": "https://storage.carrierx.com/f/7140cb0a-76a4-49fa-99a8-31ab00b71bd3", 
  "CallStatus": "", 
  "ApiVersion": "2.0", 
  "CallSid": "c996365e4043dc1d7c33a6f2829f9983", 
  "RecordingDuration": 10, 
  "RecordingStatus": "completed", 
  "To": "19093189029", 
  "CallerName": "", 
  "From": "19093189029"
}


Associate a Container With an Endpoint


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.

1. Navigate to the Configure menu, click Endpoints and select the endpoint you want to associate a container with. Click the Application: FlexML tab.



2. Click Edit .



3. Select the container you want to associate with the endpoint from the container_sid dropdown menu.



4. 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 array. Refer to the Endpoints section of the Core API Reference Guide for more information. The container_sid can be assigned when the endpoint is first created, or later through a PATCH or PUT request.