RSS/Atom Feed Sample Project
This sample skill provides an easy way to create Alexa skills that reads headlines from an RSS/Atom feed.
How to Run the Sample
To get started, you'll need to setup a few pre-requisites:
- The Node.js code will be deployed to AWS Lambda to handle requests from users passed to you from the Alexa platform.
- The skill uses a table in AWS DynamoDB to save the user's favorites and latest heard items between sessions.
- The skill uses a bucket in AWS S3 to cache the feed requested by the user.
- You can then register your skill with Alexa using the Amazon Developer website, linking it to your AWS resources.
Set these up with these step-by-step instructions:
-
Create or login to an AWS account. In the AWS Console:
-
Be sure to select "N. Virginia" as the region on the upper right.
-
Create an AWS Role in IAM with access to DynamoDB, S3 and CloudWatch logs.
-
Create an AWS Lambda function named MyFeedSkillLambdaFunction. 1. Under "Select blueprint", choose skip. 1. Under "Configure triggers", select "Alexa Skills Kit" as the trigger.
1. Under "Configure function":
1. Enter "MyFeedSkillLambdaFunction" under "Name".
1. Choose the role you created above under "Existing role".
1. Change the "Timeout" to 30 seconds, since feeds can become an issue.
1. Leave the defaults for everything else.
1. Note the ARN of the Lambda you've created, which you'll need later.
-
Create an AWS S3 Bucket with the name of your choice. Note, the S3 bucket name you choose must be unique across all existing bucket names in Amazon S3. Thus you may have to retry with another name in case of a conflict.
-
[OPTIONAL] Create an AWS DynamoDB table named MyFeedSkillTable with the case sensitive primary key "userId".
-
Create or login to an Amazon Developer account. In the Developer Console:
-
Create an Alexa Skill named MySkill and using the invocation name "my skill" and using the ARN you noted above.
Note the Skill Application Id, which you'll configure in your code later.
Set Up the Project on Your Machine
Next, you'll setup your local environment to run the deployment script.
-
Configure AWS credentials the tool will use to upload code to your Skill. You do this by creating a file under a ".aws" directory in your home directory.
-
The file should have the format, and include keys you retrieve from the AWS console:
[default] aws_access_key_id = [KEY FROM AWS] aws_secret_access_key = [SECRET KEY FROM AWS]
-
Setup NodeJS and NPM.
-
Get the code and install dependencies:
git clone https://github.com/alexa/skill-sample-nodejs-feed.git cd skill-sample-nodejs-feed/src npm install
Configure the Project to Use Your Feed
-
Open
/src/configuration.js
file. -
Update the following information to configure the skill:
- appId : Your Skill's Application ID from the Skill you created at https://developer.amazon.com.
- welcome_message : A welcome message that will be spoken to the user when they open your skill.
- number_feeds_per_prompt : The number of items the skill will read each time the user invokes it.
- display_only_feed_title : A boolean flag that determines whether to speak out the title-only or title and summary of the items in your feed.
- display_only_title_in_card : A boolean flag to decide whether to display a card with the title only or title and summary of the items in your feed.
- categories : The list of RSS feeds you want to include in your Skill. Each feed will be treated as a category.
- speech_style_for_numbering_feeds : Naming convention for each item.
- s3BucketName : Your S3 Bucket Name
- dynamoDBTableName : Your DynamoDB Table Name (If not created, the skill will create it.)
-
A sample configuration :
var config = { appId : 'amzn1.ask.skill.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', welcome_message : 'Welcome to Feed Skill', number_feeds_per_prompt : 3, display_only_feed_title : true, display_only_title_in_card : true, categories : { 'feed name' : 'http://www.example.com/rss-feed.xml' }, speech_style_for_numbering_feeds : 'Item', s3BucketName : 'my-feed-skill-bucket', dynamoDBTableName : 'MyFeedSkillBucket' };
Deploy Your Skill
-
Go to the
skill-sample-nodejs-feed/bin/
directory and rundeploy.js
using Node.npm install aws-sdk node deploy.js
-
Go to the the
skill-sample-nodejs-feed/src/
directory and zip all of the files. Be sure to only zip the files inside the directory, and not the directory itself. Lambda needs to be able to find theindex.js
file at the root of the zip file. -
Go to the AWS Console and upload the file to your Lambda function, selecting "Code entry type" as "Upload a .ZIP file".
-
Go to the Developer Portal copy following content from
skill-sample-nodejs-feed/speechAssets/
to the Interaction Model:CustomSlots-ORDINALS.txt
to a new custom slot with Type : ORDINALCustomSlots-CATEGORIES.txt
to a new custom slot with Type : CATEGORY- Note: This file is not generated. You'll need to update it with names for each of the feeds you added in your configuration above.
IntentSchema.json
to Intent Schema- Note: You'll need to create the custom slots and save them before you can submit the intent schema that references them.
Utterances.txt
to Sample Utterances
-
Start testing the skill in the Developer Portal or on your device.
-
Enjoy!
Note: By creating an Alexa skill based on the Feed skill template, you acknowledge ownership of any RSS/ATOM feed(s) used within the skill, and/or have permission to use the RSS/ATOM feed(s) from the original content owner. Failure to be able to prove ownership or permission to use any feed sources, at any time, will likely cause your skill to be rejected during the certification process, or being removed from the Alexa Skill Store without notice at a later date.