UNPKG

3.52 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, OptionItem } from './option';
19/** @public */
20export declare type CarouselArgument = OptionArgument;
21/** @public */
22export interface CarouselOptionItem extends OptionItem {
23 /**
24 * Description text of the item.
25 * @public
26 */
27 description: string;
28}
29/** @public */
30export interface CarouselOptions {
31 /**
32 * Sets the display options for the images in this carousel.
33 * @public
34 */
35 display?: Api.GoogleActionsV2UiElementsCarouselSelectImageDisplayOptions;
36 /**
37 * List of 2-20 items to show in this carousel. Required.
38 * @public
39 */
40 items: OptionItems<CarouselOptionItem> | Api.GoogleActionsV2UiElementsCarouselSelectCarouselItem[];
41}
42/**
43 * Asks to collect user's input with a carousel.
44 *
45 * @example
46 * ```javascript
47 *
48 * // Actions SDK
49 * const app = actionssdk()
50 *
51 * app.intent('actions.intent.MAIN', conv => {
52 * conv.ask('Which of these looks good?')
53 * conv.ask(new Carousel({
54 * items: {
55 * [SELECTION_KEY_ONE]: {
56 * title: 'Number one',
57 * description: 'Description of number one',
58 * synonyms: ['synonym of KEY_ONE 1', 'synonym of KEY_ONE 2'],
59 * },
60 * [SELECTION_KEY_TWO]: {
61 * title: 'Number two',
62 * description: 'Description of number one',
63 * synonyms: ['synonym of KEY_TWO 1', 'synonym of KEY_TWO 2'],
64 * }
65 * }
66 * }))
67 * })
68 *
69 * app.intent('actions.intent.OPTION', (conv, input, option) => {
70 * if (option === SELECTION_KEY_ONE) {
71 * conv.close('Number one is a great choice!')
72 * } else {
73 * conv.close('Number two is also a great choice!')
74 * }
75 * })
76 *
77 * // Dialogflow
78 * const app = dialogflow()
79 *
80 * app.intent('Default Welcome Intent', conv => {
81 * conv.ask('Which of these looks good?')
82 * conv.ask(new Carousel({
83 * items: {
84 * [SELECTION_KEY_ONE]: {
85 * title: 'Number one',
86 * description: 'Description of number one',
87 * synonyms: ['synonym of KEY_ONE 1', 'synonym of KEY_ONE 2'],
88 * },
89 * [SELECTION_KEY_TWO]: {
90 * title: 'Number two',
91 * description: 'Description of number one',
92 * synonyms: ['synonym of KEY_TWO 1', 'synonym of KEY_TWO 2'],
93 * }
94 * }
95 * }))
96 * })
97 *
98 * // Create a Dialogflow intent with the `actions_intent_OPTION` event
99 * app.intent('Get Option', (conv, input, option) => {
100 * if (option === SELECTION_KEY_ONE) {
101 * conv.close('Number one is a great choice!')
102 * } else {
103 * conv.close('Number two is also a great choice!')
104 * }
105 * })
106 * ```
107 *
108 * @public
109 */
110export declare class Carousel extends Helper<'actions.intent.OPTION', Api.GoogleActionsV2OptionValueSpec> {
111 /**
112 * @param options Carousel option
113 * @public
114 */
115 constructor(options: CarouselOptions);
116}