This is a sample Alexa Skill handler based on aws-lambda-typescript.
- Install the Serverless Application Framework as a globally available package:
$ npm install serverless -gVerify that Serverless was installed correctly:
$ serverless -v- Setup AWS credentials:
Save the credentials to the ~/.aws/credentials file:
serverless config credentials --provider aws --key YOUR_ACCESS_KEY --secret YOUR_SECRET_KEYThe default profile will be used by default. If you want to use another, you can pass the --aws-profile argument to the serverless commands. E.g.:
serverless deploy --aws-profile Work-
Clone this repository.
-
Install the dependencies:
$ npm install- Customize the name of your service by changing the following line in the
serverless.ymlfile:
service: serverless-sample- Customize the alexa skill id by changing the following line in the
serverless.ymlfile:
- alexaSkill: amzn1.ask.skill.xx-xx-xx-xx-xxDuring development, it's a pain to always have to deploy your lambda function to see your changes. There is a better way, you can connect Alexa to your local environment instead of Lambda, without having to make any modifications to your Lambda functions.
- First, we will need an HTTPS endpoint. You can use ngrok for this (it's free), or any other similar tools.
$ ./ngrok http 3980 This will give you an HTTPS endpoint which will proxy all requests to your local server (something like https://84f7599f.ngrok.io).
- Go to your skill's dashboard at the Endpoint section.
- Instead of
AWS Lambda ARN, selectHTTPS. - Now copy the https url from
ngrokand paste it in theDefault Regionfield. - For the
SSL certificate type, make sure you selectMy development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority, otherwise it will not work. - Save the changes in the Alexa developer console.
- Inside the project, run
npm start. This will start a local http server usingnodemonwhich will serve your lambda function.
Now, Alexa will be connected to your server, so you don't need to deploy to Lambda anymore.
Since the process is using nodemon, making any changes to the code will automatically restart the server, so your changes will be reflected to Alexa immediately.
For more info, check package.json and the aws-lambda-typescript documentation.
The project contains the base structure of a project, with a dummy handler for the LaunchRequest intent which responds with "Hello, world!".
- Add example test, ideally with lambda-tester, but currently it doesn't have a Typescript definition
- Fix
devDependenciesbeing packaged as well
Open sourced under the MIT license.