Skip to content

Amazon Alexa Skill to get info from KegBot written as a Lambda

License

Notifications You must be signed in to change notification settings

patfreeman/alexa-lambda-kegbot

Repository files navigation

Alexa-Lambda-Kegbot

Alexa-Lambda-Kegbot is an Alexa Skill for communication with your Kegbot. Currently it supports questions the following:

  • What's on tap?
  • How much is left?
  • Who has been drinking recently?

See intent_schema.json for all the sample utterances.

Requirements

Setup

  1. Setup a new custom Alexa Skill on https://developer.amazon.com/alexa/console/ask/create-new-skill
    1. Login
    2. Enter a Skill Name
    3. Select a language, although a lot of this is english...
    4. Choose Custom model
    5. Choose "Provision your own" method of hosting
    6. Click "Create Skill"
    7. Select the "Start from scratch" template
    8. Click "Choose"
    9. Go to the "JSON Editor" in the left nav
    10. Drag and drop a .json file, or click it and upload intent_schema.json
    11. Click "Build Model"
    12. Click "Your Skills" to return to the skill listing
    13. Click on "View Skill ID" under your Skill Name
    14. Save the Alexa Skill ID We'll come back to this later
  2. Grab the code:
    1. Clone Repo: git clone https://github.com/patfreeman/alexa-lambda-kegbot.git
    2. cd alexa-lambda-kegbot
    3. npm install
    4. cp config/default_example.js config/default.js
    5. vi config/default.js
      1. Set your Kegbot configuration. Protocol, host, port, API key (if required)
    6. zip -r ../alk.zip . NOTE: Make sure you are in the directory with the index.js file.
  3. Create Lambda
    1. In the AWS Lambda console https://console.aws.amazon.com/lambda/home?region=us-east-1#/
    2. Create a Lambda Function in us-east-1
      1. Choose "Author from scratch"
      2. Name - Give it a name
      3. Runtime - Choose Node.js 12.x
      4. Role - Choose a role or create a new one from templates(s)
      5. Role name - Enter if required
      6. Policy templates - leave blank
      7. Click "Create Function"
    3. Configure the Lambda Function
      1. Under Function code, change Code entry type to Upload a .zip file
      2. Click "Upload" and select the ZIP you created above
      3. Defaults on everything else should be good enough.
      4. Handler needs to stay as index.handler
      5. Environment variables - leave blank because we don't need any
      6. Tags - leave blank, or don't. that's up to you
      7. Description - if you care
      8. Memory - 128MB is more than enough
      9. Timeout - Set this to 10s
      10. Network - Leave as "No VPC" or if you know you need it, then you probably don't need these step by step instructions.
      11. Concurrency - Use unreserved account concurrency
      12. etc ...
      13. Click "Save" in the top-right corner of the screen.
    4. Add Alexa Skill Trigger
      1. Expand the Lambda Designer window
      2. Under Add triggers, select Alexa Skills Kit
      3. Paste in the Alexa Skill ID you saved from above
      4. Click Add
    5. Test your Lambda Function
      1. Select "Select a test event..." in the drop-down in the top-right corner
      2. Select "Configure test events"
      3. Give the test a name
      4. Paste in the code in the alexa_test_script.json file
      5. Click Create
      6. Click "Test"
      7. You should see success and the JSON response should show what is on tap on your kegbot
    6. Note ARN in upper right corner
  4. Finalize Setup
    1. Go back to Alexa Skill setup on https://developer.amazon.com/alexa/console/ask
    2. Select the Alexa Skill you created earlier
    3. Under Endpoint
      1. Choose AWS Lambda ARN
      2. Paste the ARN for your Lambda created above under Default Region
      3. Click "Save Endpoint"
    4. Test
      1. Click on the Test Tab
      2. Click the switch to enable Testing
      3. Type in phrases (or speak them) into the test interface.
      4. "ask keg bot what is on tap"
      5. "ask keg bot how much beer is left"
      6. Replace "keg bot" with your Invocation phrase you configured earlier
      7. Try talking to Alexa