UNPKG

3.21 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 { Permission } from './permission';
18/** @public */
19export declare type UpdatePermissionUserIdArgument = string;
20/** @public */
21export interface UpdatePermissionOptions {
22 /**
23 * The Dialogflow/Actions SDK intent name to be triggered when the update is received.
24 * @public
25 */
26 intent: string;
27 /**
28 * The necessary arguments to fulfill the intent triggered on update.
29 * These can be retrieved using {@link Arguments#get|conv.arguments.get}.
30 * @public
31 */
32 arguments?: Api.GoogleActionsV2Argument[];
33}
34/**
35 * Prompts the user for permission to send proactive updates at any time.
36 *
37 * @example
38 * ```javascript
39 *
40 * // Actions SDK
41 * const app = actionssdk()
42 *
43 * app.intent('actions.intent.MAIN', conv => {
44 * conv.ask(new UpdatePermission({
45 * intent: 'show.image',
46 * arguments: [{
47 * name: 'image_to_show',
48 * textValue: 'image_type_1',
49 * }
50 * ))
51 * })
52 *
53 * app.intent('actions.intent.PERMISSION', conv => {
54 * const granted = conv.arguments.get('PERMISSION')
55 * if (granted) {
56 * conv.close(`Great, I'll send an update whenever I notice a change`)
57 * } else {
58 * // Response shows that user did not grant permission
59 * conv.close('Alright, just let me know whenever you need the weather!')
60 * }
61 * })
62 *
63 * app.intent('show.image', conv => {
64 * const arg = conv.arguments.get('image_to_show') // will be 'image_type_1'
65 * // do something with arg
66 * })
67 *
68 * // Dialogflow
69 * const app = dialogflow()
70 *
71 * app.intent('Default Welcome Intent', conv => {
72 * conv.ask(new UpdatePermission({
73 * intent: 'Show Image',
74 * arguments: [{
75 * name: 'image_to_show',
76 * textValue: 'image_type_1',
77 * }
78 * ))
79 * })
80 *
81 * // Create a Dialogflow intent with the `actions_intent_PERMISSION` event
82 * app.intent('Get Permission', conv => {
83 * const granted = conv.arguments.get('PERMISSION')
84 * if (granted) {
85 * conv.close(`Great, I'll send an update whenever I notice a change`)
86 * } else {
87 * // Response shows that user did not grant permission
88 * conv.close('Alright, just let me know whenever you need the weather!')
89 * }
90 * })
91 *
92 * app.intent('Show Image', conv => {
93 * const arg = conv.arguments.get('image_to_show') // will be 'image_type_1'
94 * // do something with arg
95 * })
96 * ```
97 *
98 * @public
99 */
100export declare class UpdatePermission extends Permission {
101 /**
102 * @param options UpdatePermission options
103 * @public
104 */
105 constructor(options: UpdatePermissionOptions);
106}