UNPKG

2.87 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 { Helper } from '../helper';
18import { OptionArgument, OptionItems } from './option';
19/** @public */
20export declare type ListArgument = OptionArgument;
21/** @public */
22export interface ListOptions {
23 /** @public */
24 title?: string;
25 /** @public */
26 items: OptionItems | Api.GoogleActionsV2UiElementsListSelectListItem[];
27}
28/**
29 * Asks to collect user's input with a list.
30 *
31 * @example
32 * ```javascript
33 *
34 * // Actions SDK
35 * const app = actionssdk()
36 *
37 * app.intent('actions.intent.MAIN', conv => {
38 * conv.ask('Which of these looks good?')
39 * conv.ask(new List({
40 * items: {
41 * [SELECTION_KEY_ONE]: {
42 * title: 'Number one',
43 * synonyms: ['synonym of KEY_ONE 1', 'synonym of KEY_ONE 2'],
44 * },
45 * [SELECTION_KEY_TWO]: {
46 * title: 'Number two',
47 * synonyms: ['synonym of KEY_TWO 1', 'synonym of KEY_TWO 2'],
48 * }
49 * }
50 * }))
51 * })
52 *
53 * app.intent('actions.intent.OPTION', (conv, input, option) => {
54 * if (option === SELECTION_KEY_ONE) {
55 * conv.close('Number one is a great choice!')
56 * } else {
57 * conv.close('Number two is also a great choice!')
58 * }
59 * })
60 *
61 * // Dialogflow
62 * const app = dialogflow()
63 *
64 * app.intent('Default Welcome Intent', conv => {
65 * conv.ask('Which of these looks good?')
66 * conv.ask(new List({
67 * items: {
68 * [SELECTION_KEY_ONE]: {
69 * title: 'Number one',
70 * synonyms: ['synonym of KEY_ONE 1', 'synonym of KEY_ONE 2'],
71 * },
72 * [SELECTION_KEY_TWO]: {
73 * title: 'Number two',
74 * synonyms: ['synonym of KEY_TWO 1', 'synonym of KEY_TWO 2'],
75 * }
76 * }
77 * }))
78 * })
79 *
80 * // Create a Dialogflow intent with the `actions_intent_OPTION` event
81 * app.intent('Get Option', (conv, input, option) => {
82 * if (option === SELECTION_KEY_ONE) {
83 * conv.close('Number one is a great choice!')
84 * } else {
85 * conv.close('Number two is also a great choice!')
86 * }
87 * })
88 * ```
89 *
90 * @public
91 */
92export declare class List extends Helper<'actions.intent.OPTION', Api.GoogleActionsV2OptionValueSpec> {
93 /**
94 * @param options List options
95 * @public
96 */
97 constructor(options: ListOptions);
98}