UNPKG

8.32 kBTypeScriptView Raw
1/**
2 * Copyright 2018 Google Inc. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import * as Api from '../../api/v2';
17import { NewSurfaceArgument, PermissionArgument, OptionArgument, ConfirmationArgument, DateTimeArgument, SignInArgument, PlaceArgument, DeepLinkArgument, TransactionDecisionArgument, TransactionRequirementsArgument, DeliveryAddressArgument, RegisterUpdateArgument, UpdatePermissionUserIdArgument, CompletePurchaseArgument, DigitalPurchaseCheckArgument } from '..';
18import { RepromptArgument, FinalRepromptArgument } from './noinput';
19import { MediaStatusArgument } from './media';
20import { ApiClientObjectMap } from '../../../../common';
21export { ApiClientObjectMap };
22/** @public */
23export declare type Argument = Api.GoogleActionsV2Argument[keyof Api.GoogleActionsV2Argument];
24export interface ArgumentsNamed {
25 /**
26 * True if the request follows a previous request asking for
27 * permission from the user and the user granted the permission(s).
28 * Otherwise, false.
29 * Only use after calling {@link Permission|conv.ask(new Permission)}
30 * or {@link UpdatePermission|conv.ask(new UpdatePermission)}.
31 * @public
32 */
33 PERMISSION?: PermissionArgument;
34 /**
35 * The option key user chose from options response.
36 * Only use after calling {@link List|conv.ask(new List)}
37 * or {@link Carousel|conv.ask(new Carousel)}.
38 * @public
39 */
40 OPTION?: OptionArgument;
41 /**
42 * The transactability of user.
43 * Only use after calling {@link TransactionRequirements|conv.ask(new TransactionRequirements)}.
44 * Undefined if no result given.
45 * @public
46 */
47 TRANSACTION_REQUIREMENTS_CHECK_RESULT?: TransactionRequirementsArgument;
48 /**
49 * The order delivery address.
50 * Only use after calling {@link DeliveryAddress|conv.ask(new DeliveryAddress)}.
51 * @public
52 */
53 DELIVERY_ADDRESS_VALUE?: DeliveryAddressArgument;
54 /**
55 * The transaction decision information.
56 * Is object with userDecision only if user declines.
57 * userDecision will be one of {@link GoogleActionsV2TransactionDecisionValueUserDecision}.
58 * Only use after calling {@link TransactionDecision|conv.ask(new TransactionDecision)}.
59 * @public
60 */
61 TRANSACTION_DECISION_VALUE?: TransactionDecisionArgument;
62 /**
63 * The complete purchase information.
64 * Only use after calling {@link CompletePurchase|conv.ask(new CompletePurchase)}.
65 * @public
66 */
67 COMPLETE_PURCHASE_VALUE?: CompletePurchaseArgument;
68 /**
69 * Only use after calling {@link DigitalPurchaseCheck|conv.ask(new DigitalPurchaseCheck)}.
70 * @public
71 */
72 DIGITAL_PURCHASE_CHECK_RESULT?: DigitalPurchaseCheckArgument;
73 /**
74 * The confirmation decision.
75 * Use after {@link Confirmation|conv.ask(new Confirmation)}
76 * @public
77 */
78 CONFIRMATION?: ConfirmationArgument;
79 /**
80 * The user provided date and time.
81 * Use after {@link DateTime|conv.ask(new DateTime)}
82 * @public
83 */
84 DATETIME?: DateTimeArgument;
85 /**
86 * The status of user sign in request.
87 * Use after {@link SignIn|conv.ask(new SignIn)}
88 * @public
89 */
90 SIGN_IN?: SignInArgument;
91 /**
92 * The number of subsequent reprompts related to silent input from the user.
93 * This should be used along with the `actions.intent.NO_INPUT` intent to reprompt the
94 * user for input in cases where the Google Assistant could not pick up any speech.
95 * @public
96 */
97 REPROMPT_COUNT?: RepromptArgument;
98 /**
99 * True if it is the final reprompt related to silent input from the user.
100 * This should be used along with the `actions.intent.NO_INPUT` intent to give the final
101 * response to the user after multiple silences and should be an `conv.close`
102 * which ends the conversation.
103 * @public
104 */
105 IS_FINAL_REPROMPT?: FinalRepromptArgument;
106 /**
107 * The result of {@link NewSurface|conv.ask(new NewSurface)}
108 * True if user has triggered conversation on a new device following the
109 * `actions.intent.NEW_SURFACE` intent.
110 * @public
111 */
112 NEW_SURFACE?: NewSurfaceArgument;
113 /**
114 * True if user accepted update registration request.
115 * Used with {@link RegisterUpdate|conv.ask(new RegisterUpdate)}
116 * @public
117 */
118 REGISTER_UPDATE?: RegisterUpdateArgument;
119 /**
120 * The updates user id.
121 * Only use after calling {@link UpdatePermission|conv.ask(new UpdatePermission)}.
122 * @public
123 */
124 UPDATES_USER_ID?: UpdatePermissionUserIdArgument;
125 /**
126 * The user provided place.
127 * Use after {@link Place|conv.ask(new Place)}.
128 * @public
129 */
130 PLACE?: PlaceArgument;
131 /**
132 * The link non status argument.
133 * Is undefined as a noop.
134 * Use {@link Status#get|conv.arguments.status.get('LINK')} to explicitly get the status.
135 * @public
136 * @deprecated
137 */
138 LINK?: DeepLinkArgument;
139 /**
140 * The status of MEDIA_STATUS intent.
141 * @public
142 */
143 MEDIA_STATUS?: MediaStatusArgument;
144}
145export interface ArgumentsParsed extends ArgumentsNamed {
146 /** @public */
147 [name: string]: Argument | undefined;
148}
149/** @hidden */
150export interface ArgumentsIndexable {
151 [key: string]: Argument;
152}
153export interface ArgumentsStatus {
154 /** @public */
155 [name: string]: Api.GoogleRpcStatus | undefined;
156}
157export interface ArgumentsRaw {
158 /** @public */
159 [name: string]: Api.GoogleActionsV2Argument;
160}
161export declare class Parsed {
162 /** @public */
163 list: Argument[];
164 /** @public */
165 input: ArgumentsParsed;
166 /** @hidden */
167 constructor(raw: Api.GoogleActionsV2Argument[]);
168 /** @public */
169 get<TName extends keyof ArgumentsNamed>(name: TName): ArgumentsNamed[TName];
170 /** @public */
171 get(name: string): Argument;
172}
173export declare class Status {
174 /** @public */
175 list: (Api.GoogleRpcStatus | undefined)[];
176 /** @public */
177 input: ArgumentsStatus;
178 /** @hidden */
179 constructor(raw: Api.GoogleActionsV2Argument[]);
180 /** @public */
181 get(name: string): Api.GoogleRpcStatus;
182}
183export declare class Raw {
184 list: Api.GoogleActionsV2Argument[];
185 /** @public */
186 input: ArgumentsRaw;
187 /** @hidden */
188 constructor(list: Api.GoogleActionsV2Argument[]);
189 /** @public */
190 get(name: string): Api.GoogleActionsV2Argument;
191}
192export declare class Arguments {
193 /** @public */
194 parsed: Parsed;
195 /** @public */
196 status: Status;
197 /** @public */
198 raw: Raw;
199 /** @hidden */
200 constructor(raw?: Api.GoogleActionsV2Argument[]);
201 /**
202 * Get the argument value by name from the current intent.
203 * The first property value not named `name` or `status` will be returned.
204 * Will retrieve `textValue` last.
205 * If there is no other properties, return undefined.
206 *
207 * @example
208 * ```javascript
209 *
210 * // Actions SDK
211 * app.intent('actions.intent.PERMISSION', conv => {
212 * const granted = conv.arguments.get('PERMISSION') // boolean true if granted, false if not
213 * })
214 *
215 * // Dialogflow
216 * // Create a Dialogflow intent with the `actions_intent_PERMISSION` event
217 * app.intent('Get Permission', conv => {
218 * const granted = conv.arguments.get('PERMISSION') // boolean true if granted, false if not
219 * })
220 * ```
221 *
222 * @param argument Name of the argument.
223 * @return First property not named 'name' or 'status' with 'textValue' given last priority
224 * or undefined if no other properties.
225 *
226 * @public
227 */
228 get<TName extends keyof ArgumentsNamed>(name: TName): ArgumentsNamed[TName];
229 /** @public */
230 get(name: string): Argument;
231 /** @public */
232 [Symbol.iterator](): IterableIterator<Api.GoogleActionsV2Argument>;
233}