public class HandlerInput extends AbstractHandlerInput<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 | Field and Description |
---|---|
protected AttributesManager |
attributesManager
Manager for all skill attributes.
|
protected RequestEnvelope |
requestEnvelope
Request Envelope.
|
protected com.fasterxml.jackson.databind.JsonNode |
requestEnvelopeJson
Request envelope in JSON format.
|
protected ResponseBuilder |
responseBuilder
Response Builder.
|
protected ServiceClientFactory |
serviceClientFactory
Factory class to vend out various service clients.
|
protected TemplateFactory<HandlerInput,Response> |
templateFactory
Interface to process template and data to generate skill response.
|
context, request
Modifier | Constructor and Description |
---|---|
protected |
HandlerInput(RequestEnvelope requestEnvelope,
PersistenceAdapter persistenceAdapter,
Object context,
ServiceClientFactory serviceClientFactory,
com.fasterxml.jackson.databind.JsonNode requestEnvelopeJson,
TemplateFactory<HandlerInput,Response> templateFactory)
Constructor for HandlerInput.
|
Modifier and Type | Method and Description |
---|---|
static HandlerInput.Builder |
builder()
Static method to build an instance of Builder.
|
Optional<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. |
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. |
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
protected final RequestEnvelope requestEnvelope
protected final AttributesManager attributesManager
protected final ServiceClientFactory serviceClientFactory
protected final ResponseBuilder responseBuilder
protected final com.fasterxml.jackson.databind.JsonNode requestEnvelopeJson
protected final TemplateFactory<HandlerInput,Response> templateFactory
protected HandlerInput(RequestEnvelope requestEnvelope, PersistenceAdapter persistenceAdapter, Object context, ServiceClientFactory serviceClientFactory, com.fasterxml.jackson.databind.JsonNode requestEnvelopeJson, TemplateFactory<HandlerInput,Response> templateFactory)
requestEnvelope
- Request Envelope.persistenceAdapter
- Store skill attributes to a persistence layer.context
- object passed in when using AWS Lambda to host Skill backend code.serviceClientFactory
- Factory class to vend out various service clients.requestEnvelopeJson
- Request envelope in JSON format.templateFactory
- Interface to process template and data to generate skill response.public static HandlerInput.Builder builder()
HandlerInput.Builder
.public Optional<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 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 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 © 2023. All rights reserved.