UNPKG

7.67 kBTypeScriptView Raw
1import { DialogState, Request, RequestEnvelope, SimpleSlotValue, Slot, SlotValue, SupportedInterfaces, interfaces } from 'ask-sdk-model';
2import APIRequest = interfaces.conversations.APIRequest;
3/**
4 * Retrieves the locale from the request.
5 *
6 * The method returns the locale value present in the request. More information about the locale can be found
7 * here: https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html#request-locale
8 *
9 * @param {RequestEnvelope} requestEnvelope
10 * @return {string}
11 */
12export declare function getLocale(requestEnvelope: RequestEnvelope): string;
13/**
14 * Retrieves the type of the request.
15 *
16 * The method retrieves the request type of the input request. More information about the different request
17 * types are mentioned here:
18 * https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html#request-body-parameters
19 *
20 * @param {RequestEnvelope} requestEnvelope
21 * @return {string}
22 */
23export declare function getRequestType(requestEnvelope: RequestEnvelope): string;
24/**
25 * Retrieves the name of the intent from the request.
26 *
27 * The method retrieves the intent name from the input request, only if the input request is an {@link IntentRequest}.
28 *
29 * @param {RequestEnvelope} requestEnvelope
30 * @return {string}
31 */
32export declare function getIntentName(requestEnvelope: RequestEnvelope): string;
33/**
34 * Get request object.
35 *
36 * We can set a specific type to the response by using the generics
37 * @param {RequestEnvelope} requestEnvelope
38 * @return {Request}
39 * @example
40 * ```
41 * const intentRequest = getRequest<IntentRequest>(requestEnvelope)
42 * console.log(intentRequest.intent.name)
43 * ```
44 */
45export declare function getRequest<T extends Request>(requestEnvelope: RequestEnvelope): T;
46/**
47 * Retrieves the account linking access token from the request.
48 *
49 * The method retrieves the user's accessToken from the input request. Once a user successfully enables a skill
50 * and links their Alexa account to the skill, the input request will have the user's access token. A null value
51 * is returned if there is no access token in the input request. More information on this can be found here:
52 * https://developer.amazon.com/docs/account-linking/add-account-linking-logic-custom-skill.html
53 *
54 * @param {RequestEnvelope} requestEnvelope
55 * @return {string}
56 */
57export declare function getAccountLinkingAccessToken(requestEnvelope: RequestEnvelope): string;
58/**
59 * Retrieves the API access token from the request.
60 *
61 * The method retrieves the apiAccessToken from the input request, which has the encapsulated information of
62 * permissions granted by the user. This token can be used to call Alexa-specific APIs. More information
63 * about this can be found here:
64 * https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html#system-object
65 *
66 * The SDK automatically injects this value into service client instances retrieved from the {@link services.ServiceClientFactory}
67 *
68 * @param {RequestEnvelope} requestEnvelope
69 * @return {string}
70 */
71export declare function getApiAccessToken(requestEnvelope: RequestEnvelope): string;
72/**
73 * Retrieves the device ID from the request.
74 *
75 * The method retrieves the deviceId property from the input request. This value uniquely identifies the device
76 * and is generally used as input for some Alexa-specific API calls. More information about this can be found here:
77 * https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html#system-object
78 *
79 * @param {RequestEnvelope} requestEnvelope
80 * @return {string}
81 */
82export declare function getDeviceId(requestEnvelope: RequestEnvelope): string;
83/**
84 * Retrieves the user ID from the request.
85 *
86 * The method retrieves the userId property from the input request. This value uniquely identifies the user
87 * and is generally used as input for some Alexa-specific API calls. More information about this can be found here:
88 * https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html#system-object
89 *
90 * @param {RequestEnvelope} requestEnvelope
91 * @return {string}
92 */
93export declare function getUserId(requestEnvelope: RequestEnvelope): string;
94/**
95 * Retrieves the dialog state from the request.
96 *
97 * The method retrieves the `dialogState` from the intent request, if the skill's interaction model includes a
98 * dialog model. This can be used to determine the current status of user conversation and return the appropriate
99 * dialog directives if the conversation is not yet complete. More information on dialog management can be found here:
100 * https://developer.amazon.com/docs/custom-skills/define-the-dialog-to-collect-and-confirm-required-information.html
101 *
102 * @param {RequestEnvelope} requestEnvelope
103 * @return {DialogState}
104 */
105export declare function getDialogState(requestEnvelope: RequestEnvelope): DialogState;
106/**
107 * Returns the {@link Slot} for the given slot name from the request.
108 *
109 * This method attempts to retrieve the requested {@link Slot} from the incoming request. If the slot does not
110 * exist in the request, a null value will be returned.
111 *
112 * @param {RequestEnvelope} requestEnvelope
113 * @param {string} slotName
114 * @return {Slot}
115 */
116export declare function getSlot(requestEnvelope: RequestEnvelope, slotName: string): Slot;
117/**
118 * Returns the value from the given {@link Slot} in the request.
119 *
120 * This method attempts to retrieve the requested {@link Slot}'s value from the incoming request. If the slot does not
121 * exist in the request, a null will be returned.
122 *
123 * @param {RequestEnvelope} requestEnvelope
124 * @param {string} slotName
125 * @return {string}
126 */
127export declare function getSlotValue(requestEnvelope: RequestEnvelope, slotName: string): string;
128/**
129 * Returns the SlotValue from the given {@link Slot} in the request.
130 *
131 * SlotValue will exist for slots using multiple slot value feature. And this method attempts to retrieve the requested {@link Slot}'s SlotValue from the incoming request.
132 * If the slot or slot.slotValue does not exist in the request, null will be returned.
133 *
134 * @param {RequestEnvelope} requestEnvelope
135 * @param {string} slotName
136 * @return {SlotValue}
137 */
138export declare function getSlotValueV2(requestEnvelope: RequestEnvelope, slotName: string): SlotValue;
139/**
140 * Returns all the SimpleSlotValues from the given {@link SlotValue}.
141 * @param {SlotValue} slotValue
142 * @return {SimpleSlotValue[]}
143 */
144export declare function getSimpleSlotValues(slotValue: SlotValue): SimpleSlotValue[];
145/**
146 * Retrieves the {@link SupportedInterfaces} from the request.
147 *
148 * This method returns an object listing each interface that the device supports. For example, if
149 * supportedInterfaces includes AudioPlayer, then you know that the device supports streaming audio using the
150 * AudioPlayer interface.
151 *
152 * @param {RequestEnvelope} requestEnvelope
153 * @return {SupportedInterfaces}
154 */
155export declare function getSupportedInterfaces(requestEnvelope: RequestEnvelope): SupportedInterfaces;
156/**
157 * Returns whether the request is a new session.
158 *
159 * The method retrieves the new value from the input request's session, which indicates if it's a new session or
160 * not. More information can be found here :
161 * https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html#session-object
162 *
163 * @param requestEnvelope
164 */
165export declare function isNewSession(requestEnvelope: RequestEnvelope): boolean;
166/**
167 * Extracts slots from Dialog Api Request
168 *
169 *
170 * @param {APIRequest} apiRequest
171 */
172export declare function generateSlotsFromApiRequest(apiRequest: APIRequest): {
173 [key: string]: Slot;
174};