Business Productivity

Using AWS Lambda to automate voice recording deletion in Alexa for Business

With Alexa for Business, employees can use Alexa as their intelligent assistant to be more productive in meeting rooms, at their desks or at home. Alexa for Business has the capability to provide functionality to enrolled users (customers that have linked their personal account with their company’s Alexa for Business account) as well as shared devices (those devices owned by the organization and that are managed from the Alexa for Business AWS Console). For the purpose of this article we will be focusing on shared devices.

When it comes to data retention, the Alexa service uses and stores different types of data. Types of data that may be stored and used are such things as device location, preferred time zone, volume, and other preferences. The core of Alexa data stored are the voice recordings that are processed through text-to-speech algorithms to allow Alexa to extract the user’s intent and parameters of the query. This data is processed using Alexa services’ learning techniques to continuously improve themselves with each input.

With Alexa for Business, administrators and end-users can delete these voice recordings. Currently, Alexa for Business administrators have to access the Alexa for Business console, select each shared device, and delete voice recordings. Alternatively, end users can ask the Alexa to remove the last voice recording with the request “Alexa, delete what I just said” or for voice recordings said on that device for the day, “Alexa, delete everything I said today”. However, using these methods to ensure data is removed for hundreds or thousands of managed devices is impractical, thus we offer the ability to automate this functionality using DeleteDeviceUsageData APIs and AWS Lambda.

Solution overview

In this post, we cover how to automate voice recording data deletion on Alexa for Business once a day using AWS Lambda and AWS CloudWatch events.

Prerequisites

You should have administrative access to the following AWS services:

Also, check to ensure that you can access this GitHub Repository that contains all the instructions to create and test your own Lambda function.

System architecture

The infrastructure for automating deletion of voice recording data.

Diagram - Data Deletion process for Alexa for Business

Walk-through of key steps

To automate Alexa recording deletion, you will need to ensure the following tasks are performed.

  • Identify permissions and create the IAM role to allow the Lambda function access to write CloudWatch logs and delete utterance data through Alexa for Business.
  • Identify the Lambda requirements to execute the deletion of voice recordings on all or specific Alexa for Business shared devices that require an extra level of confidentiality.
  • Identify the time at which you would like the recordings to be deleted.
  • Identify the CloudWatch log to verify operations and deletions.

Triggered by a CloudWatch event, the Lambda script included in the GitHub repository will communicate with the Alexa for Business service. Specifically the Lambda script will:

  • Retrieve information about the shared devices (for example, listing of devices).
  • Run task to send delete voice recording request to each device.
  • Set a time to initiate a CloudWatch event to start your Lambda script
  • Retrieve output logging information and send it to CloudWatch logging.

Here’s how the Lambda script works.

1. Retrieve information about the shared devices

One function within the Lambda script will identify the shared devices listed in Alexa for Business by utilizing the searchDevices API call made available in the AWS SDK.

alexaforbusiness.searchDevices(params, function(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else console.log(data);               // successful response
});

This function is triggered by an AWS CloudWatch Event that allows the script to collect all available shared Echo devices assigned in Alexa for Business.

2. Run task to send delete voice recording request to each device.

The next function in the Lambda script will take the deviceArn of a shared Echo device and request to delete all data for that device thru the deleteDeviceUsageData API call.

alexaforbusiness.deleteDeviceUsageData(params, function(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else console.log(data);               // successful response
});
 For each device that the delete request is made to, logging from the Lambda script is sent to the CloudWatch log.

3. Set a time to initiate a CloudWatch event to start your Lambda script

Setting up a CloudWatch event to initiate the Lambda script that triggers on a schedule can be set for a fixed rate or by a schedule expression for a more refined schedule pattern.

For your Lambda script you can set the schedule to be set to once a day using a Cron expression of: 10 12 * * ? *. This will set the schedule to run each day at 12:10 AM GMT.

4. Retrieve output logging information and send it to CloudWatch logging.

An example output from the CloudWatch logs:

Action

Navigate to the GitHub Repository that contains all the instructions and the Lambda function that you need to automate voice recording deletion in Alexa for Business.

Conclusion

In this post, we showed how you can use AWS Lambda to remove retained data from your Alexa for Business shared devices thru automation using CloudWatch Events. With proper automation in place you can now manage voice data deletion in Alexa for Business for a single or an entire fleet of shared devices. IT Administrators and anyone authorized to work with these resources can view the log output on the deletion process quickly and securely, through CloudWatch logging.