Making a New Amazon Skill for The Echo

I was prompted to dive back into the Amazon Alexa Skill development by the new Alexa Hackster.io contest.

I quickly classified the development of Alexa Skills into two major categories. They don’t break them down this way, but it makes more sense to think of their development by the requirements of the developer and setup.

  1. Not user specific – Generic information and interactions available to everyone
  2. User specific – Needs information from the user like configurations, links to their devices, or specific user instances.

The non-user-specific Alexa skills are fairly simple to create and for this guide I will be creating one using Node.js in an Amazon Lambda function (their version of a cloud run process) combined with an Amazon Skill.

  1. Set up a new Amazon Lambda function (Needs to be in N.Virginia in the top right of your dashboard screen)
  2. Set up a new Amazon Skill
  3. Grab the Application Id from the newly created Amazon Skill and replace the part in the AlexaSkill.js file relating to the ApplicationId.
  4. Then upload the zip file to your Amazon Lambda function.
  5. Then define the Voice Interface using the two files in the speechAssets folder. (IntentSchema.json and SampleUtterances.txt)
  6. In your lambda function, go to the Event Sources tab, and add the “Alexa Skills Kit” Event source.
  7. Then copy your Amazon Lambda’s ARN (Amazon Resource Name) and past that into the Endpoint textbox in the Configurations Tab of your Alexa Skill – something like arn:aws:lambda-us-east-2:9081209381:function:hello-world

The user-specific Alexa skills require an endpoint that allows the user to login to your own authentication service. This in turn will require a web app and a database of stored information per user. Stay tuned for more information on how to make that happen.

At the end of my investigation of the non-user-specific Alexa skill, I created and deployed a Wind Reporting service to Alexa that allows me to use the Echo to find out what the current Wind conditions are in my city before I take my drone out for flights.

linea_2ec(0)_512

Check out the Hackster.io post for the Alexa Wind Reporting Service: https://www.hackster.io/anthony-ngu/alexa-wind-reporting-service-7aada2

Publishing an Alexa Skill

Some things to keep in mind if you are making your own Alexa Skill for global publishing.

  • You will need icons for your Alexa Skill
  • You will need to process the generic Help intent
  • You will need to process the generic Stop / Cancel intents

 

NVM – Your Node.js Friend

I’ve been doing a lot of development on an old Node.js version lately (v0.10.28) and after realizing this, tried to update my Node version only to find out that a bunch of my previous code no longer worked due to base changes since my initial download of Node.js.

After some minor digging into hosting multiple Node.js versions but being able to switch between them whenever I wanted, I came across NVM (Node Version Manager). The NVM created by Creationix supports Mac and Ubuntu users, but for Windows users there are alternatives (nvm-windows and nvmw)

The basic gist of using it is to install NVM and call “nvm install 0.10.28” or whichever version you want to install. Then you can now call “nvm use 0.10.28” from your shell window and you are using that version! It makes it super simple to switch between versions of node and also check your development compatibility across the different versions and better inform your users.

Diving into AngularJS

I’ve heard the name “AngularJS” get dropped here and there for a long time now, so I figured that it was time I delved into it a little to see what the fuss is all about.

Why AngularJS?

  1. They do a good job of making it easy to develop a website in the typical MVC (model, view, controller) fashion.
  2. Re-usability / no-repetitiveness of code with directives for elements, attributes, and class names and ng-repeat
  3. Easy to use filters on objects/data.

Here are some of what I learned from my quick dive into the world of AngularJS:

  • Within a controller, it is always better to create a reference to “this”
  • No need to pull in all the separate javascript files anymore. Bootstrap, JQuery, etc. is all included.
  • create an angular module for every “app”, website, or object based on functionality.
  • add controllers to the app for all reusable functionality / better modeling.
  • using the “ng-{keyword}” tag in your html objects gives you a massive amount of flexibility in showing, hiding, repeating, HTML elements based on JSON data, and 2-way data binding.
  • === is a comparison similar to ==
  • ng-class=”{className:variable === 3}” setting of a class based on a variable
  • INCREDIBLY EASY to use JSON data
  • forms have validity BUILT IN and allow you to toggle things based on the value
  • CSS formatting for input types:
  • Include html templates/files in other pages with:
  • Has services built in:
    • $http for fetching JSON data
    • $log for login messages to the javscript console
    • $filter for filtering an array
    • Example:

Would I use it regularly?

I believe that I have found my replacement for jquery and a good model for javascript development for the web. I definitely will be using it for most (if not all) of my websites.

Resources:

 

Node.js with SparkJS on a Website

Never used Node.js before? Want to test out SparkJS? This is the guide for you.

Background: I have done some development in Node.js before to build websites and small maker projects, but it has been a while since I touched Node.js, so I needed a refresher when I decided to work with the SparkJS package.

Things you will need:

Install node & npm

This will start up the basic express web server that you can navigate to from a web browser by going to the url: http://localhost:3000/

Create an index.html file in your myapp\views folder with the content from here:

Add another line at the end of the index.jade file that says

The whole project can be found at https://github.com/anthony-ngu/sparkjs-example

In order to download the proper node modules, you will need to run the following command from the example directory:

Reading Material: