Use the Alexa Skills Kit Samples (Custom Skills)
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
- Deploying and Testing the Samples
- Programming Concepts
- Next Steps
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 Java samples are in the amzn/alexa-skills-kit-java repository.
- The samples are in the
samples/src/main/javafolder. There is a folder for each sample.
- The JAR file for the Java library is in the
repofolder. Building the Java samples with Maven automatically installs the library to your local repository.
- The source code for Java library is provided in the
- The samples are in the
Each sample includes the following:
README.mdcontains additional information specific to the sample.
speechAssetscontains the intent schema and sample utterances, provided in text files.
IntentSchema.jsoncontain the JSON defining the intents. When you set up the Alexa skill in the developer portal, you paste this into the Intent Schema edit box on the Interaction Model page.
SampleUtterances.txt) contains the plain text sample utterances. When you set up the skill in the developer portal, you paste this into the Sample Utterances edit box on the Interaction Model page.
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:
srcfolder. The sample-specific code is in
- For the Java samples, the code is provided in a set of
.javafiles. The sample-specific code is normally in a “speechlet” class (for example,
HistoryBuffSpeechlet.java). Each sample also includes a
SpeechletRequestStreamHandlerclass, 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. For instructions, see Deploying a Sample Custom Skill to AWS Lambda.
- Alternatively, you can deploy a sample as a web service. For instance, you can deploy the sample to AWS Elastic Beanstalk. For a walk-through illustrating this scenario, see Deploying a Sample Custom Skill as a Web Service.
This table provides an index of specific coding concepts and the samples that illustrate them.
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
|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
Get started with one of the skill samples or templates::
Download the Alexa Skills Kit SDK for Node.js.
Continue in the documentation: