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

Author: Znergy

I got to school full time for Computer Science, work part time on the weekends, and spend 40/hr M-F at Epicodus (code school). I'm a growing developer and I'm learning new skills everyday.