This repository has been archived by the owner. It is now read-only.
This is a simple starter project for Alexa skills using Typescript.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.ask
lambda
models
.gitignore
LICENSE.md
README.md
gulpfile.js
nodemon.json
package-lock.json
package.json
skill.json
tsconfig.json

README.md

Alexa Skill using AWS Lambda in Typescript

This is a simple starter project for Alexa skills using Typescript.

Pre-requisites

Installation

  • Install the dependencies
$ npm install

Deployment

ASK CLI will create the skill and the Lambda function for you. The Lambda function will be created in us-east-1 (Northern Virginia) by default.

  1. Navigate to the project's root directory. you should see a file named 'skill.json' there.

  2. Deploy the skill and the Lambda function in one step by running the following command:

$ ask deploy

Local development

During 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. This will save you the time of always making deployment, and your changes will be applied instantly.

  1. 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).

  1. Open .ask/config and replace the following line
"uri": "https://YOUR_URL.ngrok.io",

with the HTTPS endpoint from ngrok, e.g.:

"uri": "https://84f7599f.ngrok.io",
  1. Now we need to update the skill endpoint to our HTTPS endpoint
$ ask deploy --target skill --profile local

You can also do this manually if you want:

  • Go to your skill's dashboard
  • Select Endpoint
  • Select HTTPS
  • Enter your HTTPS url
  • For the SSL certificate type make sure you select My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority
  1. Now we need to start the local HTTP server
$ npm start

This will start a server using express (check lambda/local/index.ts) and nodemon, which will restart the process when you make any code changes so that you don't have to.

Developer tasks

Command Description
clean Deletes the dist folder
build Builds the lambda function and exports it to the dist folder
deploy Builds the lambda function and deploys EVERYTHING (skill, model, lambda)
deploy:lambda Builds the lambda function and deploys it (just the lambda function)
deploy:local Deploys the skill details for the local profile, which will update the HTTPS endpoint
start Starts the local express server using nodemon for local development

To see the actual commands, check package.json.

Also check the ASK CLI Command Reference for more details on using the ASK CLI.

Testing

Taken from the official hello world project.

  1. To test, you need to login to Alexa Developer Console, and enable the "Test" switch on your skill from the "Test" Tab.

  2. Simulate verbal interaction with your skill through the command line (this might take a few moments) using the following example:

     $ ask simulate -l en-US -t "open greeter"
    
     ✓ Simulation created for simulation id: 4a7a9ed8-94b2-40c0-b3bd-fb63d9887fa7
    ◡ Waiting for simulation response{
      "status": "SUCCESSFUL",
      ...
  3. Once the "Test" switch is enabled, your skill can be tested on devices associated with the developer account as well. Speak to Alexa from any enabled device, from your browser at echosim.io, or through your Amazon Mobile App and say :

    Alexa, start hello world
    

Customization

Taken from the official hello world project.

  1. ./skill.json

    Change the skill name, example phrase, icons, testing instructions etc ...

    Remember than many information are locale-specific and must be changed for each locale (e.g. en-US, en-GB, de-DE, etc.)

    See the Skill Manifest Documentation for more information.

  2. ./lambda/custom/index.ts

    Modify messages, and data from the source code to customize the skill.

  3. ./models/*.json

    Change the model definition to replace the invocation name and the sample phrase for each intent. Repeat the operation for each locale you are planning to support.

  4. Remember to re-deploy your skill and Lambda function for your changes to take effect.

    $ ask deploy

License

Open sourced under the MIT license.