1 | import { canfulfill, Directive, Intent, interfaces, Response, ui } from 'ask-sdk-model';
|
2 | import AudioItemMetadata = interfaces.audioplayer.AudioItemMetadata;
|
3 | import CanFulfillIntent = canfulfill.CanFulfillIntent;
|
4 | /**
|
5 | * An interface which helps building a response.
|
6 | */
|
7 | export interface ResponseBuilder {
|
8 | /**
|
9 | * Has Alexa say the provided speech to the user
|
10 | * @param {string} speechOutput
|
11 | * @param {ui.PlayBehavior} playBehavior
|
12 | * @returns {ResponseBuilder}
|
13 | */
|
14 | speak(speechOutput: string, playBehavior?: ui.PlayBehavior): this;
|
15 | /**
|
16 | * Has alexa listen for speech from the user. If the user doesn't respond within 8 seconds
|
17 | * then has alexa reprompt with the provided reprompt speech
|
18 | * @param {string} repromptSpeechOutput
|
19 | * @param {ui.PlayBehavior} playBehavior
|
20 | * @returns {ResponseBuilder}
|
21 | */
|
22 | reprompt(repromptSpeechOutput: string, playBehavior?: ui.PlayBehavior): this;
|
23 | /**
|
24 | * Renders a simple card with the following title and content
|
25 | * @param {string} cardTitle
|
26 | * @param {string} cardContent
|
27 | * @returns {ResponseBuilder}
|
28 | */
|
29 | withSimpleCard(cardTitle: string, cardContent: string): this;
|
30 | /**
|
31 | * Renders a standard card with the following title, content and image
|
32 | * @param {string} cardTitle
|
33 | * @param {string} cardContent
|
34 | * @param {string} smallImageUrl
|
35 | * @param {string} largeImageUrl
|
36 | * @returns {ResponseBuilder}
|
37 | */
|
38 | withStandardCard(cardTitle: string, cardContent: string, smallImageUrl?: string, largeImageUrl?: string): this;
|
39 | /**
|
40 | * Renders a link account card
|
41 | * @returns {ResponseBuilder}
|
42 | */
|
43 | withLinkAccountCard(): this;
|
44 | /**
|
45 | * Renders an askForPermissionsConsent card
|
46 | * @param {string[]} permissionArray
|
47 | * @returns {ResponseBuilder}
|
48 | */
|
49 | withAskForPermissionsConsentCard(permissionArray: string[]): this;
|
50 | /**
|
51 | * Adds a Dialog delegate directive to response
|
52 | * @param {Intent} updatedIntent
|
53 | * @returns {ResponseBuilder}
|
54 | */
|
55 | addDelegateDirective(updatedIntent?: Intent): this;
|
56 | /**
|
57 | * Adds a Dialog elicitSlot directive to response
|
58 | * @param {string} slotToElicit
|
59 | * @param {Intent} updatedIntent
|
60 | * @returns {ResponseBuilder}
|
61 | */
|
62 | addElicitSlotDirective(slotToElicit: string, updatedIntent?: Intent): this;
|
63 | /**
|
64 | * Adds a Dialog confirmSlot directive to response
|
65 | * @param {string} slotToConfirm
|
66 | * @param {Intent} updatedIntent
|
67 | * @returns {ResponseBuilder}
|
68 | */
|
69 | addConfirmSlotDirective(slotToConfirm: string, updatedIntent?: Intent): this;
|
70 | /**
|
71 | * Adds a Dialog confirmIntent directive to response
|
72 | * @param {Intent} updatedIntent
|
73 | * @returns {ResponseBuilder}
|
74 | */
|
75 | addConfirmIntentDirective(updatedIntent?: Intent): this;
|
76 | /**
|
77 | * Adds an AudioPlayer play directive
|
78 | * @param {interfaces.audioplayer.PlayBehavior} playBehavior Describes playback behavior. Accepted values:
|
79 | * REPLACE_ALL: Immediately begin playback of the specified stream, and replace current and enqueued streams.
|
80 | * ENQUEUE: Add the specified stream to the end of the current queue.
|
81 | * This does not impact the currently playing stream.
|
82 | * REPLACE_ENQUEUED: Replace all streams in the queue. This does not impact the currently playing stream.
|
83 | * @param {string} url Identifies the location of audio content at a remote HTTPS location.
|
84 | * The audio file must be hosted at an Internet-accessible HTTPS endpoint.
|
85 | * HTTPS is required, and the domain hosting the files must present a valid, trusted SSL certificate.
|
86 | * Self-signed certificates cannot be used.
|
87 | * The supported formats for the audio file include AAC/MP4, MP3, HLS, PLS and M3U. Bitrates: 16kbps to 384 kbps.
|
88 | * @param {string} token A token that represents the audio stream. This token cannot exceed 1024 characters
|
89 | * @param {number} offsetInMilliseconds The timestamp in the stream from which Alexa should begin playback.
|
90 | * Set to 0 to start playing the stream from the beginning.
|
91 | * Set to any other value to start playback from that associated point in the stream
|
92 | * @param {string} expectedPreviousToken A token that represents the expected previous stream.
|
93 | * This property is required and allowed only when the playBehavior is ENQUEUE.
|
94 | * This is used to prevent potential race conditions if requests to progress
|
95 | * through a playlist and change tracks occur at the same time.
|
96 | * @param {interfaces.audioplayer.AudioItemMetadata} audioItemMetadata Metadata that can be displayed on screen enabled devices
|
97 | * @returns {ResponseBuilder}
|
98 | */
|
99 | addAudioPlayerPlayDirective(playBehavior: interfaces.audioplayer.PlayBehavior, url: string, token: string, offsetInMilliseconds: number, expectedPreviousToken?: string, audioItemMetadata?: AudioItemMetadata): this;
|
100 | /**
|
101 | * Adds an AudioPlayer Stop directive - Stops the current audio Playback
|
102 | * @returns {ResponseBuilder}
|
103 | */
|
104 | addAudioPlayerStopDirective(): this;
|
105 | /**
|
106 | * Adds an AudioPlayer ClearQueue directive - clear the queue without stopping the currently playing stream,
|
107 | * or clear the queue and stop any currently playing stream.
|
108 | *
|
109 | * @param {interfaces.audioplayer.ClearBehavior} clearBehavior Describes the clear queue behavior.
|
110 | * Accepted values:
|
111 | * CLEAR_ENQUEUED: clears the queue and continues to play the currently playing stream
|
112 | * CLEAR_ALL: clears the entire playback queue and stops the currently playing stream (if applicable).
|
113 | * @returns {ResponseBuilder}
|
114 | */
|
115 | addAudioPlayerClearQueueDirective(clearBehavior: interfaces.audioplayer.ClearBehavior): this;
|
116 | /**
|
117 | * Adds a Display RenderTemplate Directive
|
118 | * @param {interfaces.display.Template} template
|
119 | * @returns {ResponseBuilder}
|
120 | */
|
121 | addRenderTemplateDirective(template: interfaces.display.Template): this;
|
122 | /**
|
123 | * Adds a hint directive - show a hint on the screen of the echo show
|
124 | * @param {string} text plain text to show on the hint
|
125 | * @returns {ResponseBuilder}
|
126 | */
|
127 | addHintDirective(text: string): this;
|
128 | /**
|
129 | * Adds a VideoApp play directive to play a video
|
130 | *
|
131 | * @param {string} source Identifies the location of video content at a remote HTTPS location.
|
132 | * The video file must be hosted at an Internet-accessible HTTPS endpoint.
|
133 | * @param {string} title (optional) title that can be displayed on VideoApp.
|
134 | * @param {string} subtitle (optional) subtitle that can be displayed on VideoApp.
|
135 | * @returns {ResponseBuilder}
|
136 | */
|
137 | addVideoAppLaunchDirective(source: string, title?: string, subtitle?: string): this;
|
138 | /**
|
139 | * Adds canFulfillIntent to response.
|
140 | * @param {canfulfill.CanFulfillIntent} canFulfillIntent
|
141 | * @return {ResponseBuilder}
|
142 | */
|
143 | withCanFulfillIntent(canFulfillIntent: CanFulfillIntent): this;
|
144 | /**
|
145 | * Sets shouldEndSession value to null/false/true
|
146 | * @param {boolean} val
|
147 | * @returns {ResponseBuilder}
|
148 | */
|
149 | withShouldEndSession(val: boolean): this;
|
150 | /**
|
151 | * Helper method for adding directives to responses
|
152 | * @param {Directive} directive the directive send back to Alexa device
|
153 | * @returns {ResponseBuilder}
|
154 | */
|
155 | addDirective(directive: Directive): this;
|
156 | /**
|
157 | * Helper method for adding directives to reprompt
|
158 | * @param {Directive} directive the directive sent back to Alexa device
|
159 | * @returns {ResponseBuilder}
|
160 | */
|
161 | addDirectiveToReprompt(directive: Directive): this;
|
162 | /**
|
163 | * Helper method for adding Api response in the response
|
164 | * @param {any} apiResponse
|
165 | * @returns {ResponseBuilder}
|
166 | */
|
167 | withApiResponse(apiResponse: any): this;
|
168 | /**
|
169 | * Helper method for adding experimentation trigger to responses
|
170 | * @param {string} experimentId the id of the experiment that was triggered
|
171 | * @returns {ResponseBuilder}
|
172 | */
|
173 | addExperimentTrigger(experimentId: string): this;
|
174 | /**
|
175 | * Returns the response object
|
176 | * @returns {Response}
|
177 | */
|
178 | getResponse(): Response;
|
179 | }
|