UNPKG

3.01 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 { SoloHelper } from './helper';
18/** @public */
19export interface PlaceOptions {
20 /**
21 * This is the initial response by location sub-dialog.
22 * For example: "Where do you want to get picked up?"
23 * @public
24 */
25 prompt: string;
26 /**
27 * This is the context for seeking permissions.
28 * For example: "To find a place to pick you up"
29 * Prompt to user: "*To find a place to pick you up*, I just need to check your location.
30 * Can I get that from Google?".
31 * @public
32 */
33 context: string;
34}
35/** @public */
36export declare type PlaceArgument = Api.GoogleActionsV2Location | undefined;
37/**
38 * Asks user to provide a geo-located place, possibly using contextual information,
39 * like a store near the user's location or a contact's address.
40 *
41 * Developer provides custom text prompts to tailor the request handled by Google.
42 *
43 * @example
44 * ```javascript
45 *
46 * // Actions SDK
47 * const app = actionssdk()
48 *
49 * app.intent('actions.intent.MAIN', conv => {
50 * conv.ask(new Place({
51 * prompt: 'Where do you want to get picked up?',
52 * context: 'To find a place to pick you up',
53 * }))
54 * })
55 *
56 * app.intent('actions.intent.PLACE', (conv, input, place, status) => {
57 * if (place) {
58 * conv.close(`Ah, I see. You want to get picked up at ${place.formattedAddress}`)
59 * } else {
60 * // Possibly do something with status
61 * conv.close(`Sorry, I couldn't find where you want to get picked up`)
62 * }
63 * })
64 *
65 * // Dialogflow
66 * const app = dialogflow()
67 *
68 * app.intent('Default Welcome Intent', conv => {
69 * conv.ask(new Place({
70 * prompt: 'Where do you want to get picked up?',
71 * context: 'To find a place to pick you up',
72 * }))
73 * })
74 *
75 * // Create a Dialogflow intent with the `actions_intent_PLACE` event
76 * app.intent('Get Place', (conv, params, place, status) => {
77 * if (place) {
78 * conv.close(`Ah, I see. You want to get picked up at ${place.formattedAddress}`)
79 * } else {
80 * // Possibly do something with status
81 * conv.close(`Sorry, I couldn't find where you want to get picked up`)
82 * }
83 * })
84 * ```
85 *
86 * @public
87 */
88export declare class Place extends SoloHelper<'actions.intent.PLACE', Api.GoogleActionsV2PlaceValueSpec> {
89 /**
90 * @param options Place options
91 * @public
92 */
93 constructor(options: PlaceOptions);
94}