An AWS self-hosted demo skill for Amazon Alexa written in Typescript.
- Develop an Alexa Skill with Typescript.
- Self-host the skill-backend on AWS using Lambda as endpoint.
- Automate the workflow as much as possible.
- Implement tests and use additional tools to improve code quality.
- Describe the workflow in as much detail as needed for future reference.
To set up the whole environment you will need:
- Account with Amazon Web Services (AWS) - Cloud Computing Services. Make sure you set up Multi-Factor Authentication to ensure account security!
- Node.js® JavaScript runtime installed on your local machine.
- AWS Command Line Interface installed on your local machine.
- Terraform installed on your local machine.
- This repository cloned to your local machine.
This tutorial assumes that you have all this set up and ready to use.
- In AWS Console: go to IAM, create a new user and create an access key for that user
- Make sure this terraform user has the required permissions to execute the instructions during
terraform apply
. - On your local machine: run
aws configure
and enter the access keys incl. secret key as prompted.
- in
infrastructure/state.tf
: change the values according to your setup to use another (remote) backend or remove this file if you want to keep the terraform state locally. - in
infrastructure/variables.tf
: change theregion
if needed. Please note, that no all regions can host Alexa Lambda functions. Refer to Select the optimal region for your AWS Lambda function for details. - in folder
./infrastructure
: runterraform init
to set up the required modules.
-
Log in to your Alexa Developer Console
-
Enter a name and select a language. Make sure to set
Model
toCustom
andHost
toProvision your own
and pressCreate Skill
. -
The new skill will then be created within a few seconds. After completion, the skill-dashboard is shown. There should be some green checkmarks when everything went well.
-
Go to
Invocation
and choose a Skill Invocation Name. PressSave Model
andBuild Model
when done. -
Go to the
Endpoint
page. Copy the Skill ID toinfrastructure/variables.tf
(variableskill_id
). Ignore the other input fields for now.
- Open a terminal and change into the
infrastructure
folder. Executeterraform apply
to set up all the components on AWS. - Open up your AWS console (the web-interface...) in a new browser tab as we will need both consoles (Alexa Developer and AWS) simultaneously. Go to the Lambda Service and check that the lambda-function was set up correctly.
- Open up the details page and copy the ARN shown in the top right corner.
- Go back to the
Endpoint
page in your Alexa Developer Console and paste the Lambda-ARN into theDefault Region
field. Do not forget toSave Endpoints
!
-
Switch (again...) to the Lambda details page and select the
Test
button to create a new test event. -
Choose the
alexa-skill-kit-start-session
event template, enter an event name and presscreate
. -
Press
Test
again with the previously created test event selected. You should now be able to see a successful execution of the lambda-function. -
Now switch back to the
Test
page in your Alexa Developer Console and changeSkill testing is enabled in
toDevelopment
. Enabling microphone access is optional. -
Speak (while pressing the microphone button) or type the skill invocation:
open my tutorial
. If everything went well, you can hear the responses that were defined in the RequestHandlers (src/tutorial-skill.ts
). The request and response data (JSON) is also shown to the right and can be used for debugging purposes. -
Back to the AWS Lambda Console: Switch to the monitoring tab and check that the endpoint was called successful. For a detailled analysis (error messages), open the corresponding Cloudwatch Log group and select the latest Log Stream.
- Extend the Interaction Model with additional intents and utterances using the information provided on the Alexa Developer Console.
- Adapt the backend (Lambda-function) to your needs using ASK SDK for Node.js
- Developing an Alexa Skill: Part 2, Deploying to AWS Using Terraform
- Develop Alexa Custom Skill with AWS Lambda to Control IoT Device
- Skill Sample : Smarthome Switch (Node.js)