This tutorial shows you how to get started developing for Alexa with Java and Maven.
Prerequisites
- bespoken tools (bst)
$ npm install bespoken-tools -g
- Installation Instructions
- maven
- OSX with homebrew:
$ brew install maven
- Installation Instructions
- OSX with homebrew:
- Amazon Developer Account
Getting Started
Clone the bst project:
$ git clone https://github.com/bespoken/bst
Go to the sample java skill
$ cd bst/samples/java
Run the Sample Java Skill
From within bst/samples/java directory, compile the example with this command:
$ mvn compile
Run the server with this command:
$ mvn exec:java -Dexec.executable="java" -DdisableRequestSignatureCheck=true -Dexec.args=$@
The service will listen on port 9999 by default.
Start bst proxy
Open a new terminal and start the proxy for port 9999:
$ bst proxy http 9999
Configure your Skill
From the Alexa Skills Kit list within the Amazon Developer's Console:
Choose "Add a New Skill"
Fill out the Information tab
- Give your skill a name and invocation phrase, 'bst java sample' and 'greeter' for example
Fill out the Interaction Model
Configure the Endpoint
When you started the proxy, bst printed out a URL that you need to configure your skill:
$ bst proxy http 9999
BST: v1.0.4 Node: v4.3.2
Your public URL for accessing your local service:
https://your-proxy.bespoken.link
(Be sure to put in your real path and other query string parameters!)
Alternatively, you can create this URL via the proxy urlgen
command.
You first need to modify it to the path that your server is listening on, in this case it is /hello
.
https://your-proxy.bespoken.link/hello
Copy and paste this URL as your endpoint:
Also make sure you select "HTTPS" and account linking to "NO".
Configure SSL
On the SSL Certificate page, select the middle radio button "My development endpoint is a subdomain of a domain that has a wildcard certificate from a certificate authority"
Test
Go to the service simulator, and type: "hello" and hit "Ask \
You should get a valid JSON in reply:
Next Steps
You can now start adding functionality to your skill. To learn more about coding Alexa Skills, see the official documentation
You can also try it out on an Alexa device like an Echo, as long as it is registered with your account.
Just say "Open \