1 | ;
|
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 | */
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.Confirmation = void 0;
|
19 | const helper_1 = require("./helper");
|
20 | /**
|
21 | * Asks user for a confirmation.
|
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 Confirmation('Are you sure you want to do that?'))
|
31 | * })
|
32 | *
|
33 | * app.intent('actions.intent.CONFIRMATION', (conv, input, confirmation) => {
|
34 | * if (confirmation) {
|
35 | * conv.close(`Great! I'm glad you want to do it!`)
|
36 | * } else {
|
37 | * conv.close(`That's okay. Let's not do it now.`)
|
38 | * }
|
39 | * })
|
40 | *
|
41 | * // Dialogflow
|
42 | * const app = dialogflow()
|
43 | *
|
44 | * app.intent('Default Welcome Intent', conv => {
|
45 | * conv.ask(new Confirmation('Are you sure you want to do that?'))
|
46 | * })
|
47 | *
|
48 | * // Create a Dialogflow intent with the `actions_intent_CONFIRMATION` event
|
49 | * app.intent('Get Confirmation', (conv, input, confirmation) => {
|
50 | * if (confirmation) {
|
51 | * conv.close(`Great! I'm glad you want to do it!`)
|
52 | * } else {
|
53 | * conv.close(`That's okay. Let's not do it now.`)
|
54 | * }
|
55 | * })
|
56 | * ```
|
57 | *
|
58 | * @public
|
59 | */
|
60 | class Confirmation extends helper_1.SoloHelper {
|
61 | /**
|
62 | * @param text The confirmation prompt presented to the user to
|
63 | * query for an affirmative or negative response.
|
64 | * @public
|
65 | */
|
66 | constructor(text) {
|
67 | super({
|
68 | intent: 'actions.intent.CONFIRMATION',
|
69 | type: 'type.googleapis.com/google.actions.v2.ConfirmationValueSpec',
|
70 | data: {
|
71 | dialogSpec: {
|
72 | requestConfirmationText: text,
|
73 | },
|
74 | },
|
75 | });
|
76 | }
|
77 | }
|
78 | exports.Confirmation = Confirmation;
|
79 | //# sourceMappingURL=confirmation.js.map |
\ | No newline at end of file |