Create your own Alexa skill to read news using RSS feeds (Amazon Echo)

RahulV
4 min readOct 21, 2016

--

I got an Amazon Echo a few weeks back and was truly mindblown by the voice capturing and recognition. I created an Alexa skill to read me news using RSS feeds from Sportscafe.in. You can create yours too in 10 minutes. You could follow the steps in this Amazon tutorial page, with the first part (creating a lambda function) replaced by the steps listed below.

A: Configuring your Lambda function to access a public RSS feed (or any internet resource). ‘VPC Scenario 2’ described here is one way of making this happen.

  1. Go to the VPC Dashboard after clicking ‘VPC’ on your AWS Console
  2. Create a NAT Gateway using instructions from here. Your instance in a private subnet interacts with the internet via NAT Gateways.
  3. Click on ‘Start VPC Wizard’
  4. Select ‘VPC with Public and Private Subnets’ in the left panel. Learn why this important from here.
  5. Name your VPC and change any preferencees if you wish to. Enter the Elastic IP Address associated with the NAT Gateway you created.
  6. Click ‘Create VPC’.
  7. In the VPC Dashboard, click on ‘Security Groups’ in the left pane. You can learn more about Security groups here.
  8. Click on ‘Create Security Group’. Enter a group name and description.
  9. Click on the Security Group, and then ‘Inbound Rules’. Click Edit and choose ‘All Traffic’ under Type. Please note that you should never open to all traffic in an application, but the intention of this tutorial is to get a working skill, so we do this for convenience.

B: Creating a ‘Role’ for your upcoming Lambda function

  1. Click on ‘Identity & Access Management’ on your AWS Console.
  2. Click on ‘Roles’ in the left pane.
  3. Click on ‘Create Role’ and name your role.
  4. Click the Select button next to ‘AWS Lambda’ under AWS Service Roles.
  5. Select AWSLambdaFullAccess and AWSLambdaVPCAccessExecutionRole among the avaialble options
  6. Review, Note the ARN and ‘Create Role’

C: Create a ZIP file with the required files, upload to S3

Note: We are going to upload our files to a S3 bucket that our Lambda function can access. I am just uploading it to a public bucket, but you can control access to the S3 bucket.

  1. Clone this repository in your local machine https://github.com/RahulVenkatraj/AlexaNewsReaderTutorial.git
  2. In the same directory, install the python library Feedparser https://pypi.python.org/pypi/feedparser This can be done by
    pip install feedparser -t .
#Zip all the files. This can be done on your terminal 
zip -r app.zip .
  1. Click on S3 in your AWS Console.
  2. Click on ‘Create Bucket’, enter a name and complete.
  3. Inside your bucket, click the ‘Upload’ button and upload the zip file you created.

D: Creating the Alexa Skill using AWS Lambda

  1. Click on ‘Lambda’ on your AWS Console.
  2. Click on ‘Create a Lambda function’
  3. Look for the ‘alexa-skills-kit-color-expert-python’ blueprint.
  4. Choose ‘Alexa Skills Kit’ in the Configure Triggers step that comes next
  5. In the Configure Function step, enter a function name and description.
  6. In ‘Code Entry Type’, select ‘Upload a file from Amazon S3’. Find the Link URL from S3 (right click on your zip file, select properties and copy the link URL). This will be of the form: https://s3.amazonaws.com/<bucket_name>/<folder_name>/app.zip
  7. Type ‘app.lambda_handler’ in the ‘Handler’ text box. This refers to the handler function in the code you uploaded.
  8. For ‘Role’, click ‘Choose an existing role’ and choose the role that you created in Step-B.
  9. Under VPC, select the VPC you created in Step-A. In ‘Subnets’, select the private subnet that’s listed. Two subnets are recommended but 1 is good enough to work with. In Security Groups, select the security group you created in Step-A. Click Next, review and create the Lambda function.
  10. Click on ‘Test’ in your Lambda function to check if you get the intended result — a news item from Sportscafe.

You can now resume following Amazon’s tutorial here. You would want to replace references (like names and descriptions) to the ‘Colorful’ skill with the ‘Sportscafe’ skill. The following, however, will be required to be changed from the tutorial:

Intent Schema:

{
"intents": [
{
"intent": "GetNewsBySport",
"slots": [
{
"name": "SportName",
"type": "LIST_OF_SPORTS"
}
]
},
{
"intent": "GetDailyNewsDigest"
},
{
"intent": "AMAZON.HelpIntent"
},
{
"intent": "AMAZON.StopIntent"
},
{
"intent": "AMAZON.CancelIntent"
}
]
}

Add custom slot types:

Sample Utterances (be creative with this one!):

GetNewsBySport what's the latest in {SportName}
GetNewsBySport get me {SportName} news
GetNewsBySport what's happening in {SportName}
GetNewsBySport {SportName}
GetNewsBySport tell me about {SportName}
GetDailyNewsDigest what's my flash briefing
GetDailyNewsDigest flash briefing
GetDailyNewsDigest flash news
GetDailyNewsDigest flash news briefing
GetDailyNewsDigest where's my flash news briefing
GetDailyNewsDigest flash brief
GetDailyNewsDigest what's the flash brief
GetDailyNewsDigest news brief
GetDailyNewsDigest headlines
GetDailyNewsDigest get me headlines
GetDailyNewsDigest get me news
GetDailyNewsDigest get me the news
GetDailyNewsDigest what is the news
GetDailyNewsDigest what's the news
GetDailyNewsDigest read news
GetDailyNewsDigest news
GetDailyNewsDigest what's new
GetDailyNewsDigest today's news
GetDailyNewsDigest get the latest news
GetDailyNewsDigest what's the latest
GetDailyNewsDigest what happened yesterday
GetDailyNewsDigest important sports news

Follow the rest of the steps here.

Try it on your Amazon Echo device. The final output will feel like this.

https://www.youtube.com/watch?v=0Gx_azpOTCo

--

--