Making an Alexa Skill

I’m currently leading a team and we’re building an Alexa Skill, to learn the basics I followed along with a YouTube Series which shows how to create an Alexa Skill which uses YouTube API to see real statistics for viewer count and subscriber totals. The YouTube video is listed below under sources.

GitHub Repository: https://github.com/Znergy/youtube-data-alexa-skill
————————————

Alexa Skill: YouTube Data API

This Alexa Skill queries the YouTube Data API, and returns the subscriber count and viewer count based off what the user asks for.
Examples:
“Alexa, ask youtube data stream for current subscribers count”
“Alexa, ask youtube data stream for number of video views this month”

Project Requirements
To fully understand what’s taking place

You need some understanding of AWS
You need some understanding of Node.js
You need some understanding of API’s

Lambda Setup

Navigate to AWS Console, sign in, click Lambda, set geolocation (top right) as N. Virginia, click create new Lambda function
Select Blank function as template
Select Alexa Skills Kit as a trigger (see below)

You need to create an account in the Alexa Developer console for the alexa skills kit to show in the lambda trigger dropdown menu
URL: https://developer.amazon.com/

Lambda Configuration
Set lambda function name as ‘youtubeDataAPIAlexaSkill’
Create a role with basic lambda execution permission (lambda_basic_execution)
Add the temp.js code to your lambda function

YouTube API Key
Get a YouTube Data API Key from Google API Console
Go to Library, click YouTube Data API, click get credentials, and copy the API key

YouTube Channel ID
Get your channel id from YouTube Advanced Settings
Log In, click user icon, click account settings icon, click advanced (next to profile picture)
Copy Youtube Channel ID

Adding YouTube Credentials to your lambda function
Using both your YouTube API Key and YouTube Channel ID add them to the endpoint variable inside of your lambda function (code copied from temp.js)
Each different intent needs the updated endpoint for your Alexa skill to work properly
Example, https://www.googleapis.com/youtube/v3/channels?part=statistics&id=channel_id&key=your_api_key

Alexa Setup
Go to the Alexa Console, sign in, click Alexa, then click Alexa Skills Kit
Click ‘Add a New Skill’

Alexa Skill Configuration
Create an Alexa app name, I used ‘YouTube Data API’
Create an Invocation name, I used ‘youtube data stream’ (this is your Alexa skill name)
Click Next
Add the intent-schema.json code and insert into ‘Intent Schema’ section
Add the sample-utterances.txt text and insert into ‘Sample Utterances’ section
Click next
Connect your Lambda function using the ARN from AWS Lambda console
Example, arn:aws:lambda:us-east-1:xxxxxx:function:youtubeDataAPIAlexaSkill
Click next

Testing
Type a sample utterance, ex: ‘current subscriber count’ and hit ‘Ask YouTube Data API’
This should trigger your lambda function and respond with how many subscribers you have

**You can also copy the JSON request code from the test page into the AWS Lambda console, click ‘configure test event’ and see the console logs, at each state change in Alexa’s lifecycle

Reporting bugs
If any of the information above, doesn’t work or is missing a step. You can reach me at ryanjonesirl@gmail.com

Sources
YouTube: https://www.youtube.com/watch?v=zt9WdE5kR6g
AWS: https://aws.amazon.com/
Lambda: https://aws.amazon.com/lambda/
Youtube Data API: https://developers.google.com/youtube/v3/
Alexa Skills Kit: https://developer.amazon.com/alexa-skills-kit
Alexa: https://developer.amazon.com/alexa

DynamoDB and NoSQL databases

DynamoDB, a NoSQL database that is fast, scalable, fully managed, allows serverless functions called ‘lambda’, and flexible. Cherry on top, your data is stored on SSDs and automatically replicated across multiple Availability Zones, which provides high availability and data durability.

Let’s discuss our terms a bit, what is NoSQL? NoSQL is a non-relational database that utilizes many data structures like key-value, document, and many other. Let’s focus on using key-value pairs for retrieving data from the database. For key-value pairs each key can’t be replicated. The key-value method has high performance, high scalability, and high flexibility. Another ‘key’ feature of NoSQL databases, is the loss of the ability to perform joins. However, there is still a way to work around this dilemma. One instance, would be using multiple queries to attain the desired data. Since NoSQL queries are faster than relational queries this is a good method, to a certain degree. Additionally, you don’t need a database schema with NoSQL, in most cases you don’t need to explicitly define your schema up front and you can just create new fields as you need them. Very cool.

Why do people use NoSQL versus a relational database? “Motivations for this approach include: simplicity of design, simpler “horizontal” scaling to clusters of machines (which is a problem for relational databases), and finer control over availability. The data structures used by NoSQL databases (e.g. key-value, wide column, graph, or document) are different from those used by default in relational databases, making some operations faster in NoSQL. The particular suitability of a given NoSQL database depends on the problem it must solve. Sometimes the data structures used by NoSQL databases are also viewed as “more flexible” than relational database tables.”

So it depends, on the ‘problem it must solve’. Here’s an example of what those problems make look like (use cases). Example, wall street has been transformed by algorithmic trading and for the purpose of evaluating lots of conditions quickly, a relational database will not due. The high speeds of NoSQL databases have been a cornerstone in stock trading as of late.

Why I choose DynamoDB to write about. I’m currently studying to get my AWS developer and solutions architect certificate. I have an AWS study group that meets twice a week for four hours to work through a course to obtain the skills needed to deploy web applications in the cloud and get certified. So far I’ve learned enough to realize how much I don’t know. At least when it comes to deploying web applications made in Java, it’s not as simple as throwing your code in S3 (simple storage solution, aka Amazon’s version of dropbox or google drive) then configuring S3 to work as web hosting. With a Java application there is a lot more configuring and knowledge required to launch your code. Which is something I’m actively trying to tackle so I can get my Java code deployed to the cloud.

I’m planning on diving deeper into NoSQL databases, since this is what AWS is built from and realistically the future. Using DynamoDB, Amazon Lambda functions, API gateway, S3, and Route 53 you can create serverless architecture, which are super fast, dirt cheap, and freaking cool.

Sources: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Introduction.html
http://www.dataversity.net/4-use-cases-for-nosql-databases/
https://en.wikipedia.org/wiki/NoSQL