UNPKG

3.29 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.DeepLink = void 0;
19const helper_1 = require("./helper");
20const common_1 = require("../../../../common");
21/**
22 * Requests the user to transfer to a linked out Android app intent. Using this feature
23 * requires verifying the linked app in the [Actions console](https://console.actions.google.com).
24 *
25 * This feature is deprecated. Access will be by request only.
26 *
27 * @deprecated Access will be by request only
28 *
29 * @example
30 * ```javascript
31 *
32 * // Actions SDK
33 * const app = actionssdk()
34 *
35 * app.intent('actions.intent.MAIN', conv => {
36 * conv.ask('Great! Looks like we can do that in the app.')
37 * conv.ask(new DeepLink({
38 * destination: 'Google',
39 * url: 'example://gizmos',
40 * package: 'com.example.gizmos',
41 * reason: 'handle this for you',
42 * }))
43 * })
44 *
45 * app.intent('actions.intent.LINK', (conv, input, arg, status) => {
46 * // possibly do something with status
47 * conv.close('Okay maybe we can take care of that another time.')
48 * })
49 *
50 * // Dialogflow
51 * const app = dialogflow()
52 *
53 * app.intent('Default Welcome Intent', conv => {
54 * conv.ask('Great! Looks like we can do that in the app.')
55 * conv.ask(new DeepLink({
56 * destination: 'Google',
57 * url: 'example://gizmos',
58 * package: 'com.example.gizmos',
59 * reason: 'handle this for you',
60 * }))
61 * })
62 *
63 * // Create a Dialogflow intent with the `actions_intent_LINK` event
64 * app.intent('Get Link Status', (conv, input, arg, status) => {
65 * // possibly do something with status
66 * conv.close('Okay maybe we can take care of that another time.')
67 * })
68 * ```
69 *
70 * @public
71 */
72class DeepLink extends helper_1.Helper {
73 /**
74 * @param options DeepLink options
75 * @deprecated
76 * @public
77 */
78 constructor(options) {
79 common_1.deprecate('DeepLink', 'Access will be by request only');
80 const extension = {
81 '@type': 'type.googleapis.com/google.actions.v2.LinkValueSpec.LinkDialogSpec',
82 destinationName: options.destination,
83 requestLinkReason: options.reason,
84 };
85 super({
86 intent: 'actions.intent.LINK',
87 type: 'type.googleapis.com/google.actions.v2.LinkValueSpec',
88 data: {
89 openUrlAction: {
90 url: options.url,
91 androidApp: {
92 packageName: options.package,
93 },
94 },
95 dialogSpec: {
96 extension,
97 },
98 },
99 });
100 }
101}
102exports.DeepLink = DeepLink;
103//# sourceMappingURL=deeplink.js.map
\No newline at end of file