Create and deploy your first Amazon Echo (Alexa) Skill in five minutes or less!
After deploying your skill and configuring it in the Amazon Developer portal, you will be able to hold a simple conversation with Alexa:
You: "Alexa, ask my favorite color."
Alexa: "Tell me your favorite color."
You: "Red."
Alexa: ...
Alexa's brain is in the cloud, and your Alexa Skill will be no different. It will be deployed to AWS Lambda.
To successfully deploy and use your skill:
- Your Echo (or Echo Dot) must be physically set up and connected to the Internet, and associated with your Amazon account.
- AWS must be usable with your (same) Amazon account, and you need to have
AWS credentials configured on the computer where you will be working on this
project (for instance, you may use the file
$HOME/.aws/credentials
, or environment variables, or another mechanism; see this AWS article and the Developer Guide for details). - A Java 8 JDK must be installed and configured appropriately for your system
(e.g.,
JAVA_HOME
set,$JAVA_HOME/bin
on your path).
If you're fairly good at navigating through Web interfaces (like the Amazon Developer portal we'll be using), you can just follow the simple textual steps here. If you need more help, including screenshots, go to Full Steps.
- Go to your Alexa Skills Kit list in the Amazon Developer portal.
- Click Add a New Skill.
- Enter Favorite Color as the Name, and my favorite color as the Invocation Name.
- Click Save, then click Next.
- Copy your skill's app ID (near the top of the screen - it looks like
amzn1.ask.skill.xxxxx
) and paste it into the src/main/resources/app-id.properties file in your Java project. - Using skill-data.txt in your Java project as a source for
copying data:
- Copy and paste the Intent Schema JSON.
- Add a new Custom Slot Type named
COLOR
; copy and paste the list of colors. - Copy and paste the Sample Utterance.
- Click Next and wait for the model to build and the next page to appear.
- From a command prompt, in your Java project's directory, run
./gradlew alexaDeploySkill
. - Copy the Lambda ARN printed by the Gradle build script.
- Back in the Amazon Developer portal, select AWS Lambda ARN and check North America; paste the Lambda ARN printed by the Gradle script into the text box.
- Click Next.
That's it! Now you can talk with Alexa. (The first time you access a new skill, it can take a few seconds, so don't be alarmed if she doesn't respond immediately the first time.)
Say: Alexa, ask my favorite color. Then just listen and respond!
-
Go to your Alexa Skills Kit list in the Amazon Developer portal. Log in with the Amazon account to which your Echo (or Echo Dot) is attached.
Even if you use the link above, Amazon probably won't take you to the Alexa Skills Kit list if you're redirected through the login process. In this case, click ALEXA in the top menu, then click Get Started on the Alexa Skills Kit item:
You'll now see a list of skills (empty, if you haven't made a skill, before).
-
Click Add a New Skill, in the top-right corner:
-
Enter Favorite Color as the Name, and my favorite color as the Invocation Name:
Leave the other settings as the defaults.
-
Click Save:
-
Click Next:
-
Copy your skill's app ID (near the top of the screen - it looks like
amzn1.ask.skill.xxxxx
) and paste it into the src/main/resources/app-id.properties file in your Java project: -
Using skill-data.txt in your Java project as a source for copying data:
-
From a command prompt, in your Java project's directory, run
./gradlew alexaDeploySkill
(on Linux or Mac), orgradlew alexaDeploySkill
(on Windows). -
Copy the Lambda ARN printed by the Gradle build script:
-
Back in the Amazon Developer portal, select AWS Lambda ARN and check North America; paste the Lambda ARN printed by the Gradle script into the text box:
-
Click Next.
When you start fiddling with the code, here are some things to keep in mind.
There are several settings you can adjust in aws.properties to control the Gradle script's interaction with AWS:
- profile-name: Credentials profile to use if you're using a
$HOME/.aws/credentials
file for access to AWS; see the AWS CLI User Guide for more information. - lambda-function-name: Name of the Lambda created; you would use this to identify your Lambda in the AWS Web Console, for instance.
- lambda-handler: Fully-qualified name of a class that extends
SpeechletRequestStreamHandler
and will be used as the entrypoint of Alexa's call to your Lambda. - lambda-memory-mb: Memory allocated to the Lambda when it's running. The minimum amount of 128MB is more than ample for simple Speechlets like the example in this project. See the Lambda Developer Guide for more information.
- lambda-timeout-seconds: Amount of time the Lambda can run before it is forcibly terminated (from 1 to 300 seconds). See the Lambda Developer Guide for more information.
Alexa Quickstart for Java is licensed under the Apache 2.0 License - see the LICENSE.txt and NOTICE.txt files for details.