UNPKG

2.5 kBJavaScriptView Raw
1"use strict";
2/**
3 * Copyright 2018 Google Inc. All Rights Reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.RegisterUpdate = void 0;
19const helper_1 = require("./helper");
20/**
21 * Requests the user to register for daily updates.
22 *
23 * @example
24 * ```javascript
25 *
26 * // Actions SDK
27 * const app = actionssdk()
28 *
29 * app.intent('actions.intent.MAIN', conv => {
30 * conv.ask(new RegisterUpdate({
31 * frequency: 'DAILY',
32 * intent: 'show.image',
33 * arguments: [{
34 * name: 'image_to_show',
35 * textValue: 'image_type_1',
36 * }],
37 * }))
38 * })
39 *
40 * app.intent('show.image', conv => {
41 * const arg = conv.arguments.get('image_to_show') // will be 'image_type_1'
42 * // do something with arg
43 * })
44 *
45 * // Dialogflow
46 * const app = dialogflow()
47 *
48 * app.intent('Default Welcome Intent', conv => {
49 * conv.ask(new RegisterUpdate({
50 * frequency: 'DAILY',
51 * intent: 'Show Image',
52 * arguments: [{
53 * name: 'image_to_show',
54 * textValue: 'image_type_1',
55 * }],
56 * }))
57 * })
58 *
59 * app.intent('Show Image', conv => {
60 * const arg = conv.arguments.get('image_to_show') // will be 'image_type_1'
61 * // do something with arg
62 * })
63 * ```
64 *
65 * @public
66 */
67class RegisterUpdate extends helper_1.SoloHelper {
68 /**
69 * @param options RegisterUpdate options
70 * @public
71 */
72 constructor(options) {
73 super({
74 intent: 'actions.intent.REGISTER_UPDATE',
75 type: 'type.googleapis.com/google.actions.v2.RegisterUpdateValueSpec',
76 data: {
77 intent: options.intent,
78 arguments: options.arguments,
79 triggerContext: {
80 timeContext: {
81 frequency: options.frequency,
82 },
83 },
84 },
85 });
86 }
87}
88exports.RegisterUpdate = RegisterUpdate;
89//# sourceMappingURL=registerupdate.js.map
\No newline at end of file