UNPKG

8.06 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, 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 status of MEDIA_STATUS intent.
133 * @public
134 */
135 MEDIA_STATUS?: MediaStatusArgument;
136}
137export interface ArgumentsParsed extends ArgumentsNamed {
138 /** @public */
139 [name: string]: Argument | undefined;
140}
141/** @hidden */
142export interface ArgumentsIndexable {
143 [key: string]: Argument;
144}
145export interface ArgumentsStatus {
146 /** @public */
147 [name: string]: Api.GoogleRpcStatus | undefined;
148}
149export interface ArgumentsRaw {
150 /** @public */
151 [name: string]: Api.GoogleActionsV2Argument;
152}
153export declare class Parsed {
154 /** @public */
155 list: Argument[];
156 /** @public */
157 input: ArgumentsParsed;
158 /** @hidden */
159 constructor(raw: Api.GoogleActionsV2Argument[]);
160 /** @public */
161 get<TName extends keyof ArgumentsNamed>(name: TName): ArgumentsNamed[TName];
162 /** @public */
163 get(name: string): Argument;
164}
165export declare class Status {
166 /** @public */
167 list: (Api.GoogleRpcStatus | undefined)[];
168 /** @public */
169 input: ArgumentsStatus;
170 /** @hidden */
171 constructor(raw: Api.GoogleActionsV2Argument[]);
172 /** @public */
173 get(name: string): Api.GoogleRpcStatus;
174}
175export declare class Raw {
176 list: Api.GoogleActionsV2Argument[];
177 /** @public */
178 input: ArgumentsRaw;
179 /** @hidden */
180 constructor(list: Api.GoogleActionsV2Argument[]);
181 /** @public */
182 get(name: string): Api.GoogleActionsV2Argument;
183}
184export declare class Arguments {
185 /** @public */
186 parsed: Parsed;
187 /** @public */
188 status: Status;
189 /** @public */
190 raw: Raw;
191 /** @hidden */
192 constructor(raw?: Api.GoogleActionsV2Argument[]);
193 /**
194 * Get the argument value by name from the current intent.
195 * The first property value not named `name` or `status` will be returned.
196 * Will retrieve `textValue` last.
197 * If there is no other properties, return undefined.
198 *
199 * @example
200 * ```javascript
201 *
202 * // Actions SDK
203 * app.intent('actions.intent.PERMISSION', conv => {
204 * const granted = conv.arguments.get('PERMISSION') // boolean true if granted, false if not
205 * })
206 *
207 * // Dialogflow
208 * // Create a Dialogflow intent with the `actions_intent_PERMISSION` event
209 * app.intent('Get Permission', conv => {
210 * const granted = conv.arguments.get('PERMISSION') // boolean true if granted, false if not
211 * })
212 * ```
213 *
214 * @param argument Name of the argument.
215 * @return First property not named 'name' or 'status' with 'textValue' given last priority
216 * or undefined if no other properties.
217 *
218 * @public
219 */
220 get<TName extends keyof ArgumentsNamed>(name: TName): ArgumentsNamed[TName];
221 /** @public */
222 get(name: string): Argument;
223 /** @public */
224 [Symbol.iterator](): IterableIterator<Api.GoogleActionsV2Argument>;
225}