Get Custom Skill Sample Code

The Alexa Skills Kit provides several samples of custom skills written in Node.js (JavaScript) and Java. You can deploy and test these samples as AWS Lambda functions on AWS Lambda (a service offering by Amazon Web Services). Alternately, you can deploy the Java samples as a web service on a platform such as AWS Elastic Beanstalk (a service offering by Amazon Web Services).

The samples illustrate some specific concepts that are useful when designing and implementing new Alexa abilities, such as connecting to databases and other AWS services and storing information between service invocations.

Getting the Source Code for the Samples and Java Library

The samples are available as GitHub repositories. You can fork a repository to your own account and clone it to your desktop, or just download a zip file of the entire repository from GitHub.

  • The JavaScript samples are in repositories in the Alexa GitHub organization. Each sample is in its own repository. For example, the "Hello World" sample is in

  • The Java samples are in the amzn/alexa-skills-kit-java repository.

    • The samples are in the samples/src/main/java folder. There is a folder for each sample.
    • The JAR file for the Java library is in the repo folder. Building the Java samples with Maven automatically installs the library to your local repository.
    • The source code for Java library is provided in the src/com/amazon/speech folder.

Each sample includes the following:

  • contains additional information specific to the sample.
  • speechAssets contains the intent schema and sample utterances, provided in text files.
    • IntentSchema.json contain the JSON defining the intents. After you create the skill in the developer console, go to the JSON Editor box on the Build > Interaction Model page and drag and drop the file so that its contents appear in the window.
    • Utterances (orSampleUtterances.txt) contains the plain text sample utterances. Enter these sample utterances on the Launch > Store Preview" page for your skill, in the **Example Phrases section.

      When reviewing the samples to understand the Alexa Skills Kit, be sure to also review the intent schema and sample utterances. Providing good sample utterances is an important part of developing a good user experience. For recommendations for the sample utterances, see Best Practices for Sample Utterances and Custom Slot Type Values.

  • The code for the sample:
    • For the JavaScript samples, the code is in a src folder. The sample-specific code is in index.js.
    • For the Java samples, the code is provided in a set of .java files. The sample-specific code is normally in a "speechlet" class (for example, Each sample also includes a SpeechletRequestStreamHandler class, which is used as the handler when deploying the sample to AWS Lambda.

Deploying and Testing the Samples

You can set up the samples and test them with the text-based Service Simulator or an Alexa-enabled device:

  • The easiest way to experiment with a sample is to set it up as a Lambda function on AWS Lambda. Lambda functions can be written in either Node.js and Java.
  • Alternatively, you can deploy a sample as a web service. For instance, you can deploy the sample to AWS Elastic Beanstalk.

Programming Concepts

This table provides an index of specific coding concepts and the samples that illustrate them.

Concept Description Samples
DATE Slots The DATE slot type converts phrases representing absolute and relative dates into date formats. Calendar Reader
NUMBER Slots The NUMBER slot type converts numeric words into digits that you can then manipulate as numbers. Trivia
High Low Game
Custom Slot Types These types use a list of values you define for the slot. This is used for items that are not covered by Amazon's built-in set of types and is recommended for most use cases where a slot value is one of a set of possible values. How to skill
Database storage Your skill may need to persist data between sessions so that users can resume where they left off later. The Alexa Skills Kit SDK for Node.js provides handling for persisting data using AWS DynamoDB High Low Game
Long-form audio A skill can send the Alexa service directives to stream audio such as podcasts. For details, see the AudioPlayer Interface Reference. Audio Player Sample Project
Multi-stage conversation A service can manage a conversation with different stages in which you keep track of the stage the user is in. Trivia
Audio Player Sample Project
Multiple Language Support A skill can support multiple languages. The Alexa Skills Kit SDK for Node.js provides built-in handling for including multiple translations of your skill's text-to-speech and returning the correct one based on the user's locale. Trivia
How to skill
Fact skill
Session state When a user asks Alexa to perform an action that is mapped to a particular skill, this opens a new session. All requests from this user are directed to your service until the session closes. Each request sent to your service includes a flag you can use to determine whether a session is new or existing, and you can use session attributes to save data with your response during the session.

Note that the Alexa Skills Kit SDK for Node.js provides handling for session state.
High Low Game
Decision Tree
Fact skill

Next Steps

Get started with one of the skill samples or templates:

Download the Alexa Skills Kit SDK for Node.js.

Return to: Steps to Build a Custom Skill