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 | */
|
16 | import * as Api from '../../api/v2';
|
17 | import { SoloHelper } from './helper';
|
18 | /** @public */
|
19 | export declare type DateTimeArgument = Api.GoogleActionsV2DateTime;
|
20 | export interface DateTimeOptionsPrompts {
|
21 | /**
|
22 | * The initial prompt used to ask for a date and time.
|
23 | * If not provided, Google will use a generic prompt.
|
24 | * @public
|
25 | */
|
26 | initial?: string;
|
27 | /**
|
28 | * The prompt used to specifically ask for the date if not provided by user.
|
29 | * If not provided, Google will use a generic prompt.
|
30 | * @public
|
31 | */
|
32 | date?: string;
|
33 | /**
|
34 | * The prompt used to specifically ask for the time if not provided by user.
|
35 | * If not provided, Google will use a generic prompt.
|
36 | * @public
|
37 | */
|
38 | time?: string;
|
39 | }
|
40 | /** @public */
|
41 | export interface DateTimeOptions {
|
42 | /**
|
43 | * Prompts for the user
|
44 | * @public
|
45 | */
|
46 | prompts?: DateTimeOptionsPrompts;
|
47 | }
|
48 | /**
|
49 | * Asks user for a timezone-agnostic date and time.
|
50 | *
|
51 | * @example
|
52 | * ```javascript
|
53 | *
|
54 | * // Actions SDK
|
55 | * const app = actionssdk()
|
56 | *
|
57 | * app.intent('actions.intent.MAIN', conv => {
|
58 | * conv.ask(new DateTime({
|
59 | * prompts: {
|
60 | * initial: 'When do you want to come in?',
|
61 | * date: 'Which date works best for you?',
|
62 | * time: 'What time of day works best for you?',
|
63 | * }
|
64 | * }))
|
65 | * })
|
66 | *
|
67 | * app.intent('actions.intent.DATETIME', (conv, input, datetime) => {
|
68 | * const { month, day } = datetime.date
|
69 | * const { hours, minutes } = datetime.time
|
70 | * conv.close(new SimpleResponse({
|
71 | * speech: 'Great see you at your appointment!',
|
72 | * text: `Great, we will see you on ${month}/${day} at ${hours} ${minutes || ''}`
|
73 | * }))
|
74 | * })
|
75 | *
|
76 | * // Dialogflow
|
77 | * const app = dialogflow()
|
78 | *
|
79 | * app.intent('Default Welcome Intent', conv => {
|
80 | * conv.ask(new DateTime({
|
81 | * prompts: {
|
82 | * initial: 'When do you want to come in?',
|
83 | * date: 'Which date works best for you?',
|
84 | * time: 'What time of day works best for you?',
|
85 | * }
|
86 | * }))
|
87 | * })
|
88 | *
|
89 | * // Create a Dialogflow intent with the `actions_intent_DATETIME` event
|
90 | * app.intent('Get Datetime', (conv, params, datetime) => {
|
91 | * const { month, day } = datetime.date
|
92 | * const { hours, minutes } = datetime.time
|
93 | * conv.close(new SimpleResponse({
|
94 | * speech: 'Great see you at your appointment!',
|
95 | * text: `Great, we will see you on ${month}/${day} at ${hours} ${minutes || ''}`
|
96 | * }))
|
97 | * })
|
98 | * ```
|
99 | *
|
100 | * @public
|
101 | */
|
102 | export declare class DateTime extends SoloHelper<'actions.intent.DATETIME', Api.GoogleActionsV2DateTimeValueSpec> {
|
103 | /**
|
104 | * @param options DateTime options
|
105 | * @public
|
106 | */
|
107 | constructor(options: DateTimeOptions);
|
108 | }
|