This is a template of Serverless framework for Alexa skill.
- A template of Serverless Framework app for Alexa skill by Typescript
- Build by webpack
- Ready for tslint
- Output source maps
- Ready for TDD, by Jest with virtual-alexa
- Config file enable
- Support DynamoDB for Persistent Attributes.
(Ready for DynamoDB local by using serverless-dynamodb-local)
- Installing Serverless Framework
- AWS credential
Run the following command.
You can create your serverless application for Alexa Skill, based on this template.
$ serverless install --url https://github.com/HeRoMo/serverless-aws-alexa-ts --name your-app-name
$ cd your-app-name
$ npm install
Copy config/config.yml.template to config/config.yml, and modify config.yml for your skill.
$ cp config/config.yml.template config/config.yml
There are basically request hander implementations in src/handlers. Please modify these files and add other handlers for your skill.
This template include ssml-builder (with type difinition!). You can make SSML speach text easily by using this library. a tiny sample is in HelloIntentHandler.ts.
For details, please see ssml-builder.
You can manage Interaction Model JSON file of your Skill.
At first, you should run ask-cli init
for initialize ask-cli. For details, please see ask-cli document.
Next, create .npmrc file by the following command
$ echo 'skill_id = <your skill id>' > .npmrc
Then, you can get and update model by the following commands.
npm run ask:get-model # get model json from Alexa console
npm run ask:update-model # put model json to console and rebuild model
If you don't use ja_JP, please modify or add npm script of package.json for your skill language.
This template includes Jest and virtual-alexa. See a sample implementation in alexa.spec.ts.
To execute the test suite, use npm test
.
NOTICE: virtual-alexa use model json so you have to run npm run ask:get-model
before test.
( This template has a sample model json. )
If using Visual Studio Code, you can use debugger easy. This template has sample config. see .vscode/launch.json.
Run the following command to deploy your hanlder to AWS Lambda.
$ npm run sls:deploy
If you would like to use DynamoDB to persist attributes, uncomment the code for DynamoDB in index.ts and serverless.yaml.
When testing and debugging, you can use local DynamoDB
Run the following command to install local DynamoDB.
$ npm run sls:dynamodb:install
Run the following command to install local DynamoDB.
$ npm run sls:dynamodb:start
For details, please see Serverless Dynamodb Local Plugin
MIT