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 | import { SurfaceCapability } from '../surface';
|
19 | /** @public */
|
20 | export declare type NewSurfaceArgument = Api.GoogleActionsV2NewSurfaceValue;
|
21 | /** @public */
|
22 | export interface NewSurfaceOptions {
|
23 | /**
|
24 | * Context why new surface is requested.
|
25 | * It's the TTS prompt prefix (action phrase) we ask the user.
|
26 | * @public
|
27 | */
|
28 | context: string;
|
29 | /**
|
30 | * Title of the notification appearing on new surface device.
|
31 | * @public
|
32 | */
|
33 | notification: string;
|
34 | /**
|
35 | * The list of capabilities required in the surface.
|
36 | * @public
|
37 | */
|
38 | capabilities: SurfaceCapability | SurfaceCapability[];
|
39 | }
|
40 | /**
|
41 | * Requests the user to switch to another surface during the conversation.
|
42 | * Works only for en-* locales.
|
43 | *
|
44 | * @example
|
45 | * ```javascript
|
46 | *
|
47 | * // Actions SDK
|
48 | * const app = actionssdk()
|
49 | *
|
50 | * const imageResponses = [
|
51 | * `Here's an image of Google`,
|
52 | * new Image({
|
53 | * url: 'https://storage.googleapis.com/gweb-uniblog-publish-prod/images/' +
|
54 | * 'Search_GSA.2e16d0ba.fill-300x300.png',
|
55 | * alt: 'Google Logo',
|
56 | * })
|
57 | * ]
|
58 | *
|
59 | * app.intent('actions.intent.MAIN', conv => {
|
60 | * const capability = 'actions.capability.SCREEN_OUTPUT'
|
61 | * if (conv.surface.capabilities.has(capability)) {
|
62 | * conv.close(...imageResponses)
|
63 | * } else {
|
64 | * conv.ask(new NewSurface({
|
65 | * capabilities: capability,
|
66 | * context: 'To show you an image',
|
67 | * notification: 'Check out this image',
|
68 | * }))
|
69 | * }
|
70 | * })
|
71 | *
|
72 | * app.intent('actions.intent.NEW_SURFACE', (conv, input, newSurface) => {
|
73 | * if (newSurface.status === 'OK') {
|
74 | * conv.close(...imageResponses)
|
75 | * } else {
|
76 | * conv.close(`Ok, I understand. You don't want to see pictures. Bye`)
|
77 | * }
|
78 | * })
|
79 | *
|
80 | * // Dialogflow
|
81 | * const app = dialogflow()
|
82 | *
|
83 | * const imageResponses = [
|
84 | * `Here's an image of Google`,
|
85 | * new Image({
|
86 | * url: 'https://storage.googleapis.com/gweb-uniblog-publish-prod/images/' +
|
87 | * 'Search_GSA.2e16d0ba.fill-300x300.png',
|
88 | * alt: 'Google Logo',
|
89 | * })
|
90 | * ]
|
91 | *
|
92 | * app.intent('Default Welcome Intent', conv => {
|
93 | * const capability = 'actions.capability.SCREEN_OUTPUT'
|
94 | * if (conv.surface.capabilities.has(capability)) {
|
95 | * conv.close(...imageResponses)
|
96 | * } else {
|
97 | * conv.ask(new NewSurface({
|
98 | * capabilities: capability,
|
99 | * context: 'To show you an image',
|
100 | * notification: 'Check out this image',
|
101 | * }))
|
102 | * }
|
103 | * })
|
104 | *
|
105 | * // Create a Dialogflow intent with the `actions_intent_NEW_SURFACE` event
|
106 | * app.intent('Get New Surface', (conv, input, newSurface) => {
|
107 | * if (newSurface.status === 'OK') {
|
108 | * conv.close(...imageResponses)
|
109 | * } else {
|
110 | * conv.close(`Ok, I understand. You don't want to see pictures. Bye`)
|
111 | * }
|
112 | * })
|
113 | * ```
|
114 | *
|
115 | * @public
|
116 | */
|
117 | export declare class NewSurface extends SoloHelper<'actions.intent.NEW_SURFACE', Api.GoogleActionsV2NewSurfaceValueSpec> {
|
118 | /**
|
119 | * @param options NewSurface options
|
120 | * @public
|
121 | */
|
122 | constructor(options: NewSurfaceOptions);
|
123 | }
|