public interface SpeechletV2
A SpeechletV2 is a speech-enabled web service that runs in the cloud. A
SpeechletV2 receives and responds to speech initiated requests.
This is the second version, which takes in SpeechletRequestEnvelopes instead of a request
and session.
The methods in the SpeechletV2 interface define:
Because a SpeechletV2 is a cloud-based service, the life-cycle of the actual object
implementing the SpeechletV2 interface is unrelated to the life-cycle of the Alexa skill
as experienced by the user interacting with the speech enabled device. A single
SpeechletV2 object typically handles requests from many users, from many devices, for
many sessions, using many concurrent threads. Also, multiple requests that are part of a single
session coming from a single user and a single device may actually be serviced by different
SpeechletV2 objects if your service is deployed on multiple machines and load-balanced.
The Session object is what defines a single run of a skill as experienced by a user.
Session| Modifier and Type | Method and Description |
|---|---|
SpeechletResponse |
onIntent(SpeechletRequestEnvelope<IntentRequest> requestEnvelope)
Entry point for handling speech initiated requests.
This is where the bulk of the SpeechletV2 logic lives. |
SpeechletResponse |
onLaunch(SpeechletRequestEnvelope<LaunchRequest> requestEnvelope)
Entry point for
SpeechletV2s for handling a speech initiated request to start the skill
without providing an Intent.This method is only invoked when Session.isNew() is true. |
void |
onSessionEnded(SpeechletRequestEnvelope<SessionEndedRequest> requestEnvelope)
Callback used to notify that the session ended as a result of the user interacting, or not
interacting with the device.
|
void |
onSessionStarted(SpeechletRequestEnvelope<SessionStartedRequest> requestEnvelope)
Used to notify that a new session started as a result of a user interacting with the device.
|
void onSessionStarted(SpeechletRequestEnvelope<SessionStartedRequest> requestEnvelope)
SpeechletV2s to perform initialization logic and allows for session
attributes to be stored for subsequent requests.requestEnvelope - the session started request envelopeSpeechletResponse onLaunch(SpeechletRequestEnvelope<LaunchRequest> requestEnvelope)
SpeechletV2s for handling a speech initiated request to start the skill
without providing an Intent.Session.isNew() is true.requestEnvelope - the launch request envelopeSpeechletResponse onIntent(SpeechletRequestEnvelope<IntentRequest> requestEnvelope)
SpeechletV2 logic lives. Intent requests are handled by
this method and return responses to render to the user.SpeechletV2 session, Session.isNew()
returns true. Otherwise, this is a subsequent request within an existing session.requestEnvelope - the intent request envelope to handlevoid onSessionEnded(SpeechletRequestEnvelope<SessionEndedRequest> requestEnvelope)
SpeechletV2 itself
ended the session using SpeechletResponse.setShouldEndSession(boolean).requestEnvelope - the end of session request envelopeCopyright © 2016. All rights reserved.