public class ResponseBuilder extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Object |
apiResponse
Object to include in response. |
protected CanFulfillIntent |
canFulfillIntent
Instance of
CanFulfillIntent. |
protected Card |
card
Output in card format.
|
protected List<Directive> |
directiveList
List of device directives.
|
protected ExperimentTriggerResponse |
experimentTriggerResponse
ExperimentTriggerResponse to include in response. |
protected Reprompt |
reprompt
Reprompt message to keep the session open.
|
protected Boolean |
shouldEndSession
Determines if the current session should end or not.
|
protected OutputSpeech |
speech
Output speech.
|
| Constructor and Description |
|---|
ResponseBuilder() |
| Modifier and Type | Method and Description |
|---|---|
ResponseBuilder |
addAudioPlayerClearQueueDirective(ClearBehavior clearBehavior)
Adds an AudioPlayer
ClearQueueDirective to the response. |
ResponseBuilder |
addAudioPlayerPlayDirective(PlayBehavior playBehavior,
Long offsetInMilliseconds,
String expectedPreviousToken,
String token,
String url)
Adds an AudioPlayer
PlayDirective to the response. |
ResponseBuilder |
addAudioPlayerPlayDirective(PlayBehavior playBehavior,
Long offsetInMilliseconds,
String expectedPreviousToken,
String token,
String url,
AudioItemMetadata metadata)
Adds an AudioPlayer
PlayDirective to the response. |
ResponseBuilder |
addAudioPlayerStopDirective()
Adds an AudioPlayer
StopDirective to the response. |
ResponseBuilder |
addConfirmIntentDirective(Intent updatedIntent)
Adds a Dialog
ConfirmIntentDirective to the response. |
ResponseBuilder |
addConfirmSlotDirective(String slotName,
Intent updatedIntent)
Adds a Dialog
ConfirmSlotDirective to the response. |
ResponseBuilder |
addDelegateDirective(Intent updatedIntent)
Adds a Dialog
DelegateDirective to the response. |
ResponseBuilder |
addDirective(Directive directive)
Adds a given
Directive to the response. |
ResponseBuilder |
addElicitSlotDirective(String slotName,
Intent updatedIntent)
Adds a Dialog
ElicitSlotDirective to the response. |
ResponseBuilder |
addExperimentTrigger(String experimentId)
Adds a given experimentId to the Experiment Trigger response.
|
ResponseBuilder |
addHintDirective(String hintText)
Adds a
HintDirective to the response. |
ResponseBuilder |
addRenderTemplateDirective(Template template)
Adds a Display
RenderTemplateDirective to the response. |
ResponseBuilder |
addVideoAppLaunchDirective(String source,
String title,
String subtitle)
Adds a VideoApp
LaunchDirective to the response to play a video. |
Optional<Response> |
build()
Builds an instance of Response to be returned to the client.
|
ResponseBuilder |
withApiResponse(Object apiResponse)
Sets the
Object object in the response. |
ResponseBuilder |
withAskForPermissionsConsentCard(List<String> permissions)
Sets a
AskForPermissionsConsentCard card on the response. |
ResponseBuilder |
withCanFulfillIntent(CanFulfillIntent canFulfillIntent)
Helper method for adding canFulfillIntent to response.
|
ResponseBuilder |
withCard(Card card)
Sets a
Card object on the response. |
ResponseBuilder |
withLinkAccountCard()
Sets a
LinkAccountCard on the response. |
ResponseBuilder |
withReprompt(String text)
Sets
Reprompt speech on the response. |
ResponseBuilder |
withReprompt(String text,
Directive directive)
Sets
Reprompt speech on the response. |
ResponseBuilder |
withReprompt(String text,
Directive directive,
PlayBehavior playBehavior)
Sets
Reprompt speech on the response. |
ResponseBuilder |
withReprompt(String text,
PlayBehavior playBehavior)
Sets
Reprompt speech on the response. |
ResponseBuilder |
withShouldEndSession(Boolean shouldEndSession)
Sets whether the session should end after this response.
|
ResponseBuilder |
withSimpleCard(String cardTitle,
String cardText)
Sets a simple
Card on the response with the specified title and content. |
ResponseBuilder |
withSpeech(String speechText)
Sets
OutputSpeech on the response. |
ResponseBuilder |
withSpeech(String speechText,
PlayBehavior playBehavior)
Sets
OutputSpeech on the response. |
ResponseBuilder |
withStandardCard(String cardTitle,
String cardText,
Image image)
Sets a standard
Card on the response with the specified title, content and image. |
protected OutputSpeech speech
protected Card card
protected Boolean shouldEndSession
protected Reprompt reprompt
protected CanFulfillIntent canFulfillIntent
CanFulfillIntent.protected ExperimentTriggerResponse experimentTriggerResponse
ExperimentTriggerResponse to include in response.public Optional<Response> build()
Response.public ResponseBuilder withSpeech(String speechText)
OutputSpeech on the response. Speech is always wrapped in SSML tags.speechText - speech textpublic ResponseBuilder withSpeech(String speechText, PlayBehavior playBehavior)
OutputSpeech on the response. Speech is always wrapped in SSML tags.speechText - speech textplayBehavior - determines the queuing and playback of this output speechpublic ResponseBuilder withCard(Card card)
Card object on the response.card - card objectpublic ResponseBuilder withSimpleCard(String cardTitle, String cardText)
Card on the response with the specified title and content.cardTitle - title for cardcardText - text in the cardpublic ResponseBuilder withStandardCard(String cardTitle, String cardText, Image image)
Card on the response with the specified title, content and image.cardTitle - title for cardcardText - text in the cardimage - imagepublic ResponseBuilder withLinkAccountCard()
LinkAccountCard on the response.public ResponseBuilder withAskForPermissionsConsentCard(List<String> permissions)
AskForPermissionsConsentCard card on the response.permissions - permission arraypublic ResponseBuilder withReprompt(String text)
Reprompt speech on the response. Speech is always wrapped in SSML tags.text - reprompt textpublic ResponseBuilder withReprompt(String text, Directive directive)
Reprompt speech on the response. Speech is always wrapped in SSML tags.text - reprompt textdirective - Directive objectpublic ResponseBuilder withReprompt(String text, PlayBehavior playBehavior)
Reprompt speech on the response. Speech is always wrapped in SSML tags.text - reprompt textplayBehavior - determines the queuing and playback of this output speechpublic ResponseBuilder withReprompt(String text, Directive directive, PlayBehavior playBehavior)
Reprompt speech on the response. Speech is always wrapped in SSML tags.text - reprompt textdirective - Directive objectplayBehavior - determines the queuing and playback of this output speechpublic ResponseBuilder withShouldEndSession(Boolean shouldEndSession)
shouldEndSession - whether session should end or not, or nullpublic ResponseBuilder withApiResponse(Object apiResponse)
Object object in the response.apiResponse - Object to include in the response.
The API response is a free form type. Values provided should be
either primitive Java types or complex types serializable by Jackson's
ObjectMapper.public ResponseBuilder addHintDirective(String hintText)
HintDirective to the response.hintText - hint textpublic ResponseBuilder addVideoAppLaunchDirective(String source, String title, String subtitle)
LaunchDirective to the response to play a video.source - location of video content at a remote HTTPS locationtitle - title that can be displayed on VideoAppsubtitle - subtitle that can be displayed on VideoApppublic ResponseBuilder addRenderTemplateDirective(Template template)
RenderTemplateDirective to the response.template - display templatepublic ResponseBuilder addDelegateDirective(Intent updatedIntent)
DelegateDirective to the response.updatedIntent - updated intentpublic ResponseBuilder addElicitSlotDirective(String slotName, Intent updatedIntent)
ElicitSlotDirective to the response.slotName - name of slot to elicitupdatedIntent - updated intentpublic ResponseBuilder addConfirmSlotDirective(String slotName, Intent updatedIntent)
ConfirmSlotDirective to the response.slotName - name of slot to elicitupdatedIntent - updated intentpublic ResponseBuilder addConfirmIntentDirective(Intent updatedIntent)
ConfirmIntentDirective to the response.updatedIntent - updated intentpublic ResponseBuilder addAudioPlayerPlayDirective(PlayBehavior playBehavior, Long offsetInMilliseconds, String expectedPreviousToken, String token, String url)
PlayDirective to the response.playBehavior - Describes playback behavioroffsetInMilliseconds - The timestamp in the stream from which Alexa should begin playbackexpectedPreviousToken - A token that represents the expected previous streamtoken - A token that represents the audio stream. This token cannot exceed 1024 charactersurl - Identifies the location of audio content at a remote HTTPS locationpublic ResponseBuilder addAudioPlayerPlayDirective(PlayBehavior playBehavior, Long offsetInMilliseconds, String expectedPreviousToken, String token, String url, AudioItemMetadata metadata)
PlayDirective to the response.playBehavior - Describes playback behavioroffsetInMilliseconds - The timestamp in the stream from which Alexa should begin playbackexpectedPreviousToken - A token that represents the expected previous streamtoken - A token that represents the audio stream. This token cannot exceed 1024 charactersurl - Identifies the location of audio content at a remote HTTPS locationmetadata - Stream's metadata that can be displayed on AudioPlayerpublic ResponseBuilder addAudioPlayerStopDirective()
StopDirective to the response.public ResponseBuilder addAudioPlayerClearQueueDirective(ClearBehavior clearBehavior)
ClearQueueDirective to the response.clearBehavior - Describes the clear queue behaviorpublic ResponseBuilder addDirective(Directive directive)
Directive to the response.directive - directive to send with the response back to the Alexa devicepublic ResponseBuilder addExperimentTrigger(String experimentId)
experimentId - the identifier of the experiment that is executedpublic ResponseBuilder withCanFulfillIntent(CanFulfillIntent canFulfillIntent)
canFulfillIntent - canFulfillIntent.Copyright © 2023. All rights reserved.