This code will create a movie review app for an Alexa skill
To create an Alexa skill to coincide with my website, thatdarngirlmovie.reviews. User will get the last 5 reviews for movies that are In The Theater, Made for TV, Video on Demand, and In Stores. For English Speaking Great Britain and the United States, uses can purchase access to Early Screening reviews and a searchable Library. Some reviews in the Library will be exclusives because they will never be featured in the main app. User add In Store review items to their Amazon cart.
Built with
- Amazon S3
- Alexa Skill Kit
- Alexa Shopping Kit
- AWS Lambda
- AWS CodePipeline
- Amazon Aurora
- In Skill Purchasing
- AWS Secrets Manager
- Alexa Presentation Language (APL)
- GitHub
- NodeJS 10.x
When this code is git push'ed to master branch, it triggers your CodePipeline to build the code in the Development Lambda Function. Once built, it waits for the user to manually test in the Alexa Development Console. If the test is labeled successful, the CodePipeline will build the code in the Production Lambda Function. This will change the skill to all production customers.
- Release-1.0.0: Uses Node.js 6.10 without Alexa Skills Cards
- Release-1.1.0: Uses Node.js 6.10 with Alexa Skills Cards
- Release-2.0.0: Uses Node.js 8.10 with Alexa Skills Cards and optimized for the Echo Show and the Echo Spot
- Release-2.0.1: Release-2.0.0 with bug fixes
- Release-3.0.0: Updated with the Alexa Presentation Language (APL) which optimizes this skill for Echo Spot, Echo Show 1st Gen, Echo Show 2nd Gen, and Fire TV (FTC Affiliate Disclaimer)
- Release-4.0.0: Uses Node.js 10.15 with In Skill Purchasing for English speaking US and English Speaking Great Britian. Adds a library backed by Aurora DB and Early Screening Reviews. Changed Must Buy to In Stores
- Release-4.1.0: Updated NPM packages, added support for Echo Spot 5, updated the Logo, updated APL to version 1.1, and bug fixes.
- Release-4.1.1: Updated CodePipeline with more robust CodeBuilds
- Release-4.1.2: Update NodeJS from version 10 to version 14. Updates had to be made to the Lambda function, AWS CodeBuild, and the package.json.
- Release-5.0.0: Updated APL to version 1.6 for improved tablet support, updated templates, and increases response time. Also, several bug fixes
- Release-5.0.1: Updated APL for movieoptions and getList for version 1.8 to support using images as buttons
- Release-5.1.0: Add Alexa Shopping Kit to In Stores section of the US locale and updated the APL for all locales
- Release-5.2.0: Update NodeJS from version 14 to version 18
- Data Folder
- earlyScreening.js - contains data for the Early Screening section
- inTheTheater.js - contains data for the In The Theater section
- madeForTV.js - contains data for the Made For TV section
- mustBuy.js - contains data for the In Stores section
- videoOnDemand.js - contains data for the Video On Demand section
- Helpers Folder
- getCardInfo.js - returns information about a specific movie for the Alexa Skills Card
- getList.js - returns the json for Alexa devices with screens
- getOptions.js - creates a string for Alexa to say
- getReview.js - returns the review in the data file
- JSON Folder
- background.json - sets background images for APL design. If you change the image here, it will change everywhere
- help.json - sets up APL design for the help page
- librarywelcome.json - sets up APL design for the library home page
- movieoptions.json - sets up APL design for the movie options section
- review.json - sets up APL design for the movie review
- welcome.json - sets up APL deign for the home, help, and goodbye screen
- index.js This contains the code with helper functions for each Intent listed in the next section.
First, you must have an account on the Alexa Developer Console. Then create a new skill. The following are the Intents, followed by their sample utterences, and their slots. Also, you need a a development and production Lambda function for the system to call. And you need the images in a public S3 bucket with CORS turned off. Italics are for EN-US and EN-GB only.
Intent | Sample Utterances | Slot Name | Slot Type |
---|---|---|---|
Commands | {command} Please {command} |
command | USER_COMMAND |
MenuSelection | {menu} | menu | MENU_OPTIONS |
MovieChoices | show me {choice} tell me about {choice} select {choice} i choose {choice} {choice} |
choice | LETTER_CHOICE |
CancelPurchaseIntent | {Verbs} my subscription {Verbs} my {ProductName} subscription {Verbs} {ProductName} subscription {verbs} subscription to {Verbs} my subscription etc |
Verbs ProductName |
LIST_OF_VERBS LIST_OF_PRODUCT_NAMES |
BuyIntent | to purchase {ProductName} to buy {ProductName} i would like {ProductName} i want {ProductName} would like {ProductName} |
ProductName | LIST_OF_PRODUCT_NAMES |
WhatCanIBuy | purchase what can i buy what can i shop for tell me what can i buy etc |
||
Library | look for {query} look for {MovieList} search for {query} search for {MovieList} lookup {query} etc |
query MovieList |
Amazon.SearchQuery LIST_OF_MOVIES} |
Slot Types | Value |
---|---|
USER_COMMAND | main menu movie options repeat |
MENU_OPTIONS | Video on Demand In Stores Made for TV In The Theater Early Screening Library |
LETTER_CHOICE | 1 through 5 6 through 10 |
LIST_OF_VERBS | stop refund return end cancel |
LIST_OF_PRODUCT_NAMES | Premium Access |
LIST_OF_MOVIES | List of all the movies in the database |
Amazon.SearchQuery | Name the slot query |
Create a subscription product and note its ARN and Product Name.
First, you must have an account on the Alexa Developer Console to test. Open your Alexa skill and click the "Test" tab. To start, say the following invocation "Open [Invocation of your choice]". Then follow the prompts. Listen for grammar and spelling errors.
Create an account on the Alexa Developer Console and the AWS Management Console. In the Alexa Developer Console, create a skill with the above mention intents, sample utterances, and slots. First create a Role with the following permissions
- SecretsManagerReadWrite
- AmazonRDSDataFullAccess
- AWSLambdaBasicExecutonRole
- AWSLambdaVPCAccessExecutionRole
CREATE TABLE reviews (
ID int NOT NULL AUTO_INCREMENT,
Title varchar(255) NOT NULL,
Rating float NOT NULL,
Image varchar(255) NOT NULL,
Review blob(4000) NOT NULL,
PRIMARY KEY (ID)
);
Next, create an AWS Secrets Manager with the automatic rotation disabled. Then, in the AWS Management Console, create 2 Lambda functions with
- Trigger: Alexa Skills Kit
- Runtime: Node.js 10.x
- Environment Variables
- database: Database name
- productID: ARN number of the ISP created
- productName: Name used when ISP was created
- resourceArn: Aurora ARN
- secretArn: Secret Manager ARN
- skillAdds: A sentence to tell the users what movies have been added to the skill
- libraryAdds: A sentence to tell the users what movies have been added to the library
- Code entry type: Upload a .zip file
- Timeout: 0 to 8 seconds
- Execution Role: Role created above
Create a CodePipeline. The CodeCommit should use your GitHub Repo with this code. The CodeBuild should run the following steps:
cd lambda
npm install
zip -r ../OOOOOOO.zip *
cd ..
aws lambda update-function-code --function-name DDDDDDD --zip-file fileb://OOOOOOO.zip
Replace the DDDDDDD with your Lambda Dev function name. Replace the OOOOOOO with your desired zip file name. Add a manual Testing step to the CodePipeline. The Test section above will explain how to use the Alexa Developer Console to test. Finally, add a CodeBuild step to push your code to production.
cd lambda
npm install
zip -r ../OOOOOOO.zip *
cd ..
aws lambda update-function-code --function-name PPPPPPP --zip-file fileb://OOOOOOO.zip
Replace the PPPPPPP with your Lambda Prod function name.
To make suggestions for code changes, fixes, or updates, please email thebestdarngirls@gmail.com
That Darn Girl