Custom application allow users to find closest library with a book title
Sample voice interaction:
- User: Alexa, launch WorldCat.
- Alexa: Ask me to find a book for you. For example, you can say, "Where can I find 'On the Road'?"
- User: Where can I find "On the Road"?
- Alexa: The closest library where you can find "On the Road" by Kerouac, Jack is Worthington Libraries. Do you need the library's address?
- User: Yes.
- Alexa: I've sent the address to your device.
- Card displays on Amazon Alexa app and/or Echo device:
- Worthington Libraries / 820 High Street, Worthington, OH, 43085, United States
- User: Find public libraries near me
- Alexa: The nearest public library is "Worthington Libraries / 820 High Street, Worthington, OH, 43085, United States"
Clone this repository
$ git clone {url}
or download directly from GitHub.
Change into the application directory
Download node and npm and use the install
command to read the dependencies JSON file
$ npm install
- Request a WSKey for WorldCat Search API and WorldCat Registry API - http://platform.worldcat.org/wskey/
- a Sandbox WSKey will work fine for this demo
- Copy example_config.yml to prod_config.yml . Open prod_config.yml and edit to include:
- wskey
- secret
- zip_code
- Install AWS Commandline tools
- https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html I reccomend using pip.
- Create an AWS user in IAM console. Give it appropriate permissions. Copy the key and secret for this user to use in the CLI.
- Configure the commandline tools - https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html
- Make sure you add -- key/secret -- region
-
Create a KMS key
-
Encrypt the config file
$ aws kms encrypt --key-id {key-id} --plaintext fileb://prod_config.yml --output text --query CiphertextBlob --output text | base64 -D > prod_config_encrypted.txt
- Use serverless to test locally
serverless invoke local --function checkOCLCNumber --path alexa_launch_event.json
##Installing in AWS Lambda
- Download and setup the application, see Installing locally
- Edit serverless.yml so it includes your key ARN
region: us-east-1
iamRoleStatements:
- Effect: Allow
Action:
- kms:Decrypt
Resource: { "Fn::Join" : ["", ["arn:aws:kms:${self:provider.region}:", { "Ref" : "AWS::AccountId" }, ":key/{key-id}" ] ] }
- Deploy the code using serverless
$ serverless deploy
- Go to the AWS Lambda console
- Make sure the role for the Lambda has the right permissions: KMS decrypt
- Setup the Alexa Skill Kit trigger on the Lambda
- Note the ARN for the Lambda
- Create or sign in to your Amazon Developer Console.
- Select Your Alexa Dashboards.
- Select Alexa Skills Kit.
- Add a New Skill.
- Skill Information:
- Name = "Ask WorldCat"
- Invocation Name = "world cat"
- Leave all the other default options.
- Save > Next
- Interaction Model:
- Go to JSON Editor: copy and paste the contents of model.json.
- Save > Next
- Configuration:
- Service Endpoint Type:
- Select "AWS Lambda ARN"
- Copy and paste your AWS Lambda ARN into the text box.
- Leave all the other default options.
- Save > Next
- Service Endpoint Type:
- Test your Skill using the Voice Simulator or the Service Simulator in the Developer Console.
- For example, entering the text "Where can I find Hillbilly Elegy?" in the Service Simulator will produce a request and response