This tutorial shows you how to get started developing for Alexa with Java and Maven.

Prerequisites

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

  • Copy and paste the Intent Schema from here
  • Copy and paste the Sample Utterances from here

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:

Alexa Skill Configuration

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:

Test your Skill

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 \" to use it.