My Second Alexa App

White House Facts

For my second Alexa skill, I wrote a White House trivia app based on the Space Geek demonstration project.

Customizing the app

This project was much more straightforward than the prior one, as I now understand better what’s going on behind the scenes and the difference between what the Lambda AWS and the Alexa Developer portals do.

The specification on the app said “dozens”, so I was a little concerned about finding enough interesting info about the building. Constructing the fact list turned out to be very easy, as I “bumped into” new White House-related topics when I thought I was going to run out of ideas.

Software

For my last app, I used Sublime Text 3 exclusively. This time around, I experimented with Aptana Studio 3. There were things I liked about both apps, but the UI for Aptana Studio 3 is getting a little long in the tooth. Despite being an older app, I found Aptana to be somewhat slow. Even though setup of Sublime Text 3 is a bit of a pain, I think it’s my preferred editor for working with JavaScript files due to snappier response, ability to customize, and third-party linters.

Challenge

Prior to the Amazon Echo project, I’ve had limited experience with languages outside of Objective-C and Swift. I’ve found JavaScript generally very easy to work with and very similar to Swift, but I’ve grown spoiled with Xcode telling me instantly when and where I make a mistake in code. Unlike the last app, this time around we need to go back and modify var APP_ID in index.js after submitting files to Lambda.

Initial value for var APP_ID

var APP_ID = undefined; //replace with "amzn1.echo-sdk-ams.app.[your-unique-value-here]";

My initial update to var APP_ID

var APP_ID = amzn1.echo-sdk-ams.app.[your-unique-value-here];

Everything was going well until I got to testing. When I attempted to test an utterance, values populated the Lambda request window:

`{
	"session": {
		"sessionId": "SessionId.[blah-blah]",
		"application": {
		"applicationId": "amzn1.echo-sdk-ams.app.blah-blah"
		},
	"user": {
		"userId": "amzn1.ask.account.blah-blah"
		},
	"new": true
		},
	"request": {
		"type": "LaunchRequest",
		"requestId": "EdwRequestId.blah-blah",
		"timestamp": "2016-04-12T00:52:50Z",
		"locale": "en-US"
		},
	"version": "1.0"
}`

In the Lambda response window, I got the following:

`The remote endpoint could not be called, or the response it returned was invalid.`

I was baffled, as all I’d done with the Space Geek file was altered the questions and updated variable names from spaceGeek to myApp and SpaceGeek to MyApp. After linting, I discovered I left s off the string value in the var APP_ID variable declaration. Changing it to:

var APP_ID = "amzn1.echo-sdk-ams.app.[your-unique-value-here]";

and re-submitting the file resolved the issue. Here’s how I felt when it worked.

Lesson Learned

Lint your files before submitting them.