This was originally published on the Clarify blog on 29 May 2014.
“This call may be recorded for quality assurance.”
You’ve heard it a thousand times but how often is it true? How often does a company record those calls? More importantly, what do they do with those recordings?
Many organizations don’t do anything with the recordings. They go into the giant network storage in the sky to collect digital dust. Other organizations attach the recordings to customer records along with some notes and call it a day. Finally, other organizations are investing in making these calls searchable, collecting common words, and trying to identify common threads of problems earlier.
So how can you accomplish the same without spending millions of dollars and months of effort?
The easiest way is to integrate your call recording system directly with Clarify. In fact, if you use a system like Twilio – which has Recording Callbacks – you can make the indexing near-realtime with almost no effort.
Install Twilio & Clarify libraries
Our first step is getting the helper libraries for both Twilio and Clarify. Luckily, through the power that is Composer, we can do that with a simple configuration file and single command. Here’s our composer.json:
{
"require": {
"clarify/clarify-helper": "dev-master",
"twilio/sdk": "dev-master"
}
}
and then we run composer install which will configure our libraries automatically.
Next, we need to accept the incoming phone call and record it. This can be accomplished with a trivial amount of TwiML (or Twilio XML) to greet the caller and record:
<Response>
<Say>Your call will now be recorded</Say>
<Record action="store-in-clarify.php" maxLength="60" />
</Response>
Using the Recording Webhook
The key aspect of that snippet is the action attribute on the Record TwiML. Once the recording is completed, Twilio will make an HTTP POST to the file specified in it. In addition to the regular call information we receive – To and From for example – the POST will also include a RecordingUrl. That gives us the next step: audio indexing.
<?php
include 'vendor/autoload.php';
$apiKey = 'update with your api key';
// The preg_replace just filters the to/from information to make sure we're only dealing with numbers.
// It may be overkill in this case but better safe than sorry.
$to = $_POST['To'];
$to = preg_replace("/[^0-9]/", "", $to);
$from = $_POST['From'];
$from = preg_replace("/[^0-9]/", "", $from);
$recording_url = $_POST['RecordingUrl'];
$jsonData = '{"to": "'.$to.'", "from": "'.$from.'"}';
$bundle = new Clarify\Bundle('my api key');
$bundle->create('phone recording', $recording_url, $jsonData, '', '');
In this case, we’ll collect those three parameters – To, From, RecordingUrl – and pass them into Clarify. The RecordingUrl takes the place of our media url and is parsed accordingly. On the other hand, we use the To and From information in our metadata field. As Ivo talked about in “Searching Audio and Video Metadata [Clarify blog post on metadata search]” earlier this week, we can use this information to do advanced searches and even filtering. By inserting the To and From information, we can build a query that says “show me every time anyone from this number said this word.” If we wanted, we could query a CRM and add even more information to our metadata fields.. but that’s beyond the scope of this post.
Embedding the Clarify Audio Player
From here, we our stock audio player from Github and plug in our PHP helper library and our API key and in minutes we have a player that looks like the screencap below:
How many phone calls does your company make? How many of them are recorded and collect digital dust? We hope to change that and let you open that information to drive new and useful insights and features for your organization. You can explore and continue this project from the Clarify/Twilio on Github.
If you’d like to get in touch, don’t hesitate: keith@clarify.io or @CaseySoftware on Twitter.
