This is an Alexa skill to hear random facts about cats, built with the Alexa.Net library.
The Alexa skill is driven by a lambda function and reads facts from a DynamoDB table.
Much of the code in this project is adapted from the June λ# hackathon challenge to create an Alexa AdventureBot skill.
Make sure the following tools are installed on your computer.
In addition, you will need both an Amazon Developer account and an AWS account.
NOTE: The AWS Lambda function for Alexa Skills must be deployed in us-east-1
This project uses a profile named alexa. Use the following steps to set up this profile, or modify the aws-lambda-tools-defaults.json file to use an existing profile.
- Create an
alexaprofile:aws configure --profile alexa - Configure the profile with the AWS credentials you want to use
Create an Alexa-CatFacts role from the AWS console. The role will need to have access to DynamoDB and CloudWatchLogs.
- In the AWS developer console, create a DynamoDB table to hold your facts.
- Add facts to your table.
Items can be batch loaded into the DynamoDB table from the a specifically-formatted JSON file via the AWS CLI using the following command:
aws dynamodb batch-write-item --request-items file://assets/cat-facts.json
Batch writes are limited to 25 table rows. Updates must be made using the update-item action instead. For more information, see the AWS CLI documentation.
- Navigate to the Lambda function directory:
cd src/CatFacts - Restore solution packages:
dotnet restore - Publish the lambda function:
dotnet lambda deploy-function - Navigate to the published lambda function.
- Under
Code>Environment Variables- Add key:
catfacts_db - Add the DynamoDB table name as the value
- Click 'Save'.
- Add key:
- Under
Triggers- Click
Add Trigger - Select
Alexa Skills Kit - Click
Submit(NOTE: ifSubmitis grayed out, selectAlexa Smart Hometrigger instead and then selectAlexa Skills Kittrigger again)
- Click
- Log into the Amazon Developer Console
- Click on the
ALEXAtab - Click on Alexa Skill Kit
Get Started - Click
Add a New Skill - Skill Information
- Under name put:
CatFacts - Under invocation name put:
Cat Facts - Click
Save - Click
Next
- Under name put:
- Interaction Model
- Click
Launch Skill Builder - Click
Discardto proceed - Click
</> Codein left navigation - Upload
assets/alexa-skill.jsonfile - Click
Apply Changes - Click
Build Modein the toolbar - Click
Configuration
- Click
- Configuration
- Select
AWS lambda ARN (Amazon Resource Name) - Select
North America - Copy the AWS lambda function ARN from its page in the developer console, and paste it in the Alexa skill configuration:
arn:aws:lambda:us-east-1:******:function:Alexa-CatFacts - Click
Next
- Select
- Your Alexa Skill is now available on all your registered Alexa-devices, including the Amazon mobile app.
- For Alexa devices, say:
Alexa, open Cat Facts - For the Amazon mobile app, click the microphone icon, and say:
open Cat Facts - Then say,
Give me a cat fact, or any other custom and built-in intents. - Say
quitto exit the skill.
- For Alexa devices, say: