# Debugging your Java voice apps locally with Bespoken

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 (opens new window) within the Amazon Developer's Console:

Click on the "Create Skill" button

Fill out the Information tab

  • Give your skill a name, 'greeter' for example
  • Click on the "Create Skill" button

Leave the default "Start from scratch" option and click on "Choose"

Fill out the Interaction Model

  • Copy the Interaction Model from here (opens new window)
  • Click on the "JSON Editor" from the Interaction Model Options
  • Paste the Interaction Model
  • Click on the "Save Model" button
  • Click on the "Build Model" button

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: v2.3.14  Node: v8.9.4

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!)

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 this URL as your endpoint, then:

  • Select the "Endpoint" option in your skill configuration
  • Select "HTTPS" for your service endpoint type
  • Paste the proxy url
  • On the SSL Certificate Option, select the middle option "My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority"

# Test

  • Go to the "Test" tab in the skill Configuration
  • Enable testing for development by clicking in the selector on the top of the page, it starts in "Off" by default.
  • On the service simulator, type: "Ask hello world".

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 (opens new window)

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