public class HandlerInput extends AbstractHandlerInput<com.amazon.ask.model.Request>
RequestHandler
, ExceptionHandler
,
RequestInterceptor
,
and ResponseInterceptor
.
Contains the RequestEnvelope
, AttributesManager
,
ServiceClientFactory
, ResponseBuilder
,
and other useful utilities.Modifier and Type | Class and Description |
---|---|
static class |
HandlerInput.Builder
HandlerInput Builder.
|
Modifier and Type | Method and Description |
---|---|
static HandlerInput.Builder |
builder()
Static method to build an instance of Builder.
|
Optional<com.amazon.ask.model.Response> |
generateTemplateResponse(String responseTemplateName,
Map<String,Object> dataMap)
Generate
Response using skill response template and injecting data. |
AttributesManager |
getAttributesManager()
Returns an
AttributesManager which can be used to retrieve and store skill attributes. |
com.amazon.ask.model.RequestEnvelope |
getRequestEnvelope()
Returns the
RequestEnvelope of the incoming request. |
com.fasterxml.jackson.databind.JsonNode |
getRequestEnvelopeJson()
Returns a
JsonNode representation of the incoming Request Envelope. |
ResponseBuilder |
getResponseBuilder()
Returns a
ResponseBuilder that can be used to construct a complete skill response containing speech,
directives, etc. |
com.amazon.ask.model.services.ServiceClientFactory |
getServiceClientFactory()
Returns a
ServiceClientFactory used to retrieve service client instances that can call Alexa APIs. |
boolean |
matches(Predicate<HandlerInput> predicate)
Evaluates a
Predicate against the current handler input state. |
getContext, getRequest
public static HandlerInput.Builder builder()
HandlerInput.Builder
.public Optional<com.amazon.ask.model.Response> generateTemplateResponse(String responseTemplateName, Map<String,Object> dataMap) throws TemplateFactoryException
Response
using skill response template and injecting data.
Response template contains response components including but not limited to
OutputSpeech
, Card
, Directive
and CanFulfillIntent
and placeholders for injecting data.
Injecting data provides component values to be injected into template.responseTemplateName
- name of response templatedataMap
- a map that contains injecting dataTemplateFactoryException
- if fail to load or render template using provided
TemplateLoader
or TemplateRenderer
public com.amazon.ask.model.RequestEnvelope getRequestEnvelope()
RequestEnvelope
of the incoming request.public AttributesManager getAttributesManager()
AttributesManager
which can be used to retrieve and store skill attributes.public com.fasterxml.jackson.databind.JsonNode getRequestEnvelopeJson()
JsonNode
representation of the incoming Request Envelope.public com.amazon.ask.model.services.ServiceClientFactory getServiceClientFactory()
ServiceClientFactory
used to retrieve service client instances that can call Alexa APIs.IllegalStateException
- if this method is called when an ApiClient
is
not configured on this SDK instance.public boolean matches(Predicate<HandlerInput> predicate)
Predicate
against the current handler input state.predicate
- predicate to evaluatepublic ResponseBuilder getResponseBuilder()
ResponseBuilder
that can be used to construct a complete skill response containing speech,
directives, etc.Copyright © Amazon.com, Inc. or its affiliates. All Rights Reserved.