Make Your Logs Work for You

The days of logging in to servers and manually viewing log files are over. SolarWinds® Papertrail™ aggregates logs from applications, devices, and platforms to a central location.

View Technology Info

FEATURED TECHNOLOGY

Troubleshoot Fast and Enjoy It

SolarWinds® Papertrail™ provides cloud-based log management that seamlessly aggregates logs from applications, servers, network devices, services, platforms, and much more.

View Capabilities Info

FEATURED CAPABILITIES

Aggregate and Search Any Log

SolarWinds® Papertrail™ provides lightning-fast search, live tail, flexible system groups, team-wide access, and integration with popular communications platforms like PagerDuty and Slack to help you quickly track down customer problems, debug app requests, or troubleshoot slow database queries.

View Languages Info

FEATURED LANGUAGES

TBD - APM Integration Title

TBD - APM Integration Description

TBD Link

APM Integration Feature List

TBD - Built for Collaboration Title

TBD - Built for Collaboration Description

TBD Link

Built for Collaboration Feature List

Blog > How to Log Amazon Alexa Apps and Improve User Experience

How to Log Amazon Alexa Apps and Improve User Experience

Posted by By telliott on December 21, 2018

Alexa is Amazon’s cloud-based voice service and brain behind millions of devices including the Echo family of devices. It is capable of voice interaction, controlling smart devices, and performing common and basic mobile tasks such as music playback, making lists, and purchasing items. It is the interface for consumer automated home systems and an operating system for the Internet of Things. The majority of millennial consumers (71%) report using voice assistants daily, while 46% report interacting five times or more.

The voice industry is still in its infancy and has challenges. Web and mobile applications track UX through clicks, but what can we do for voice? Voice assistants are routinely puzzled by commands they don’t understand or can’t perform. Collecting misunderstood phrases, unavailable skills, and customer issues reveals trends, creating a roadmap for desired user features.

Efficiently managing this data is made easier with a log management tool. In this tutorial, we’ll show you to log from Alexa skills. Our skill is written as an Amazon Lambda function and we’ll show you how to track logs to Papertrail. Then, you can identify common misunderstood phrases and use them to improve your voice app. By reading this article, you will learn how to connect hardware to the Internet of Things (IoT), log the data it sends you, and leverage that data to improve your product.

How Voice Apps Are Built With Lambda

AWS Lambda is a hosting service that runs code, manages computing resources, and sends data to various log management programs. It simplifies the process of y building smaller, on-demand applications that are responsive to new information. It also responds to website clicks, inputs from IoT devices, and voice commands.

Alexa Skills Kit

Amazon provides a vast array of resources for developers to learn how to build voice applications with the Amazon Skills Kit (ASK). ASK is a collection of self-service APIs, tools, documentation, and code samples.

What Is Papertrail | How Does It Help?

SolarWinds Papertrail® is a cloud-hosted log management solution. It allows you to access your log data through a web browser. It makes it easy to aggregate logs from your entire deployment in one location. It lets you search logs, tail in real time from multiple devices and troubleshoot issues. Critical events require human attention, and Papertrail can alert you via email, Slack, or HTTP webhooks.

It’s a good idea to log instances when Alexa misunderstands the user’s command or is commanded beyond the Skill’s capabilities. These instances demonstrate important customer desires. If the customer uses new phrasing or asks commands that are unavailable, then this is an opportunity to make your skill more intuitive and useful.

Our Demo App

In this tutorial, we show you how to build an app that unlocks a door using your voice. You don’t need a physical lock to complete the tutorial, because you can see the locking and unlocking actions in your console.

The skill runs in a AWS Lambda function which stores logs in CloudWatch Logs. We use a tool called Paperwatch running in another Lambda function to send the logs to Papertrail. We’ll also show you how to set up these resources using CloudFormation.

Diagram showing the components used this tutorial. © 2018 Google. All rights reserved.

If you haven’t created an Alexa skill before, you can do so by following Voice First’s Smart Lock tutorial on YouTube. If you already have an Alexa skill, you can use that instead. Just apply the examples to your existing skill.

Smart Lock YouTube Playlist © 2018 YouTube. All rights reserved.

How to Send Logs From Lambda Functions to Papertrail

This tutorial has several requirements. We’ll assume you have an existing Alexa skill or have followed the above video to set one up. Additionally, we will be using Node.js in our Lambda functions. Will also assume you have installed AWS command line tools. If you need help installing and configuring them, please see Amazon’s documentation.

Create an S3 Bucket

First, we’ll create an S3 bucket to hold our Lambda function code. Log in to or sign up for an Amazon Web Services (AWS) Account. Create an AWS S3 bucket named “lambda-papertrail-demo” by going to your AWS Console and selecting AWS Services > S3. Choose Create bucket, name the bucket “lambda-papertrail-demo”, and set the region to US East (N. Virginia). Click Next, Next, and Create Bucket.

Amazon S3 console © 2018 Amazon Web Services. All rights reserved

Create an AWS Administrator IAM User and Group

  • Go to your AWS Console, under Services, find Security, Identity, and Compliance, and select IAM. Select Users, then Add user, and enter the user name: “Administrator”.
  • Select the check box next to AWS Management Console access, select Custom password, type your new password, and select Next: Permissions.
  • On the Set Permissions page choose Create group. Name the group “Administrators”, check the box “AdministratorAccess”, and create the group. Back in the list of groups, select the check box for your new group. Choose Refresh if necessary to see the group in the list. Then, choose Next: Review followed by Create user. You should receive a success message and a box containing your new Access key ID and Secret access key. Be sure to record or download these access keys.
IAM permissions © 2018 Amazon Web Services. All rights reserved

Papertrail Setup

Log into or sign up for a Papertrail account. Then, create a Papertrail log group named “lambda-papertrail-pt-log-group”.

Papertrail dashboard © 2018 SolarWinds LLC. All rights reserved.

In the Papertrail dashboard, choose Create Group, name it “lambda-papertrail-pt-log-group”, and select Create Group. Back on the dashboard choose Settings, Log Destinations, and Create Log Destination.In the “Add new systems to a group” dropdown select “lambda-papertrail-pt-log-group”, choose Create, and click Update. In Log Destinations, locate the destination you just created and note your host (logs7.papertrailapp.com) and port (16092).

Papertrail log destinations © 2018 SolarWinds LLC. All rights reserved

Configure PaperWatch

Clone the PaperWatch repository at $ git clone https://github.com/Signiant/PaperWatch.git. Open the PaperWatch file in your text editor and choose the “config” folder then the “paperwatch.json” file. Configure host and port with the IDs from above, and delete or change retentionPeriod (optional: log group’s retention period in days).

Configuration file in VS Code © 2018 Microsoft Corporation. All rights reserved.

Save this file, then run the build script paperwatch $ npm run build which will install dependencies and create the lambda.zip deployment package. Upload the deployment package to the S3 bucket with paperwatch $ aws s3 cp ./lambda.zip s3://lambda-papertrail-demo

Lambda files © 2018 Linux. All rights reserved.

Create a Stack in AWS CloudFormation

Go to your AWS Console, and, in Services, find CloudFormation under Management Tools. Choose Create new stack, fill in the bubble of Upload a template to Amazon S3, choose File, Select the deploy.cfn.json file located at ~PaperWatch/cfn/deploy.cfn.json, choose Next, and name the stack “lambda-papertrail-demo-stack”. In the SourceBucket box enter “lambda-papertrail-demo” and in the SourceKey box “lambda.zip”. Choose Next and under Capabilities check the I acknowledge that AWS CloudFormation might create IAM resources box. Finally, click on Create.

Checkpoint: Determine if you completed the previous steps correctly

Go to your AWS Console and navigate to Lambda. Choose Functions, you should see three functions as pictured below:

Lambda functions © 2018 Amazon Web Services. All rights reserved.

Clone the Demo App

Clone https://github.com/Voice-First-Tech/Smart-Lock.git, and open up the Smart Lock file in your text editor. In the app.js file, inside of the “LAUNCH” intent, insert a console.log message to be sent to the file and upload it to Lambda. Create a function for it.

‘LAUNCH’: function() {
console.log(‘The Smart Lock app was launched! Lambda-papertrail-demo  log test’);
if (!this.getAccessToken()) {

Deploy to AWS Lambda

In your ~Smart-Lock/voice-first-tech folder, zip all folders and files and name “lambda-papertrail-demo.zip”.

Zipping up files © 2018 Apple. All rights reserved

Go to your AWS Console and navigate to Lambda. Choose Create function, name it “lambda-papertrail-demo-function”, and select Create Function. Navigate to the function dashboard: Lambda > Functions > lambda-papertrail-demo-function. Under Function Code, click the drop down Code entry type, then choose Upload a .zip file and upload your lambda-papertrail.demo.zip. (Tip: To avoid quick timeouts, scroll down to Basic Settings and change it to 30 seconds.) Scroll to the top and choose Save.

Test the Lambda Function

Below the ARN in the top right corner of the AWS Lambda dashboard, click the drop down Select a test event, Configure test event, Create new test event, Event Template: Amazon Alexa Start Session, and name the event “lambdaPapertrailDemoTest”. Back on the lambda-papertrail-demo-function dashboard, start the test by choosing Test. You should see this:

Lambda execution result © 2018 Amazon Web Services. All rights reserved.

Under Log output, choose Click here to navigate to the /aws/lambda/lambda-papertrail-demo-function log group. You can also navigate to the same place by selecting AWS Console Services, Management Tools, CloudWatch, and then click Logs tab, which is where you find /aws/lambda/lambda-papertrail-demo-function. Under Log Streams click the most recent log name. Inside you should see your log message.

Lambda log output © 2018 Amazon Web Services. All rights reserved.

If you see the above log message, you are now successfully logging to CloudWatch.

View the Logs in Papertrail

To navigate to Papertrail and observe the logs in the group log, go to your Papertrail dashboard and select the lambda-papertrail-pt-log-group. If everything is configured correctly, you will see your console.log message from inside the LAUNCH intent in app.js:

Papertrail logs © 2018 2018 SolarWinds LLC. All rights reserved.

Congratulations! You have successfully delivered your log messages from your Amazon Alexa Skill to Papertrail!

By clicking the bar graph button (red arrow), you are able to view the Velocity Graph feature of Papertrail. The Velocity graph shows how many logs/minute were received at that time. Our test app only has a single log from our test at this point. Now is a good time to add more log statements to your code. For example, you may want to log an error message every time the app cannot understand the user. You can use this data in the velocity chart to see how often this happens. If there are too many errors in a certain amount of time, you can set an alert to notify your team.

What’s Next?

Papertrail accelerates the processes of gathering demographic data, user origin data, and user behavior. It can help you increase user retention and find new avenues to drive growth. Now you can take advantage of an always-running, real-time, massive focus group comprising 100% of your users. Consumers are curious about voice feedback, push its limits, know its limitations, and test it often. Alexa can even ask questions back and log answers. Gathering survey data is frictionless with voice compared to annoying pop-up ratings and surveys on web and mobile apps.

Click here for a free trial of SolarWinds Papertrail. You will be able to track Amazon Alexa skills or any other application from which you wish to track logs.