Skip to content
This repository was archived by the owner on May 28, 2024. It is now read-only.

Commit ed9f6d5

Browse files
committed
Add conv.canvas.state feature
Bug: 161934922 Change-Id: I59ef8958c196315aa63b14a6ae61d719d29bc646
1 parent 0407a09 commit ed9f6d5

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

src/service/actionssdk/api/v2.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,6 +1726,11 @@ export interface GoogleActionsV2Input {
17261726
* A list of provided argument values for the input requested by the Action.
17271727
*/
17281728
arguments?: GoogleActionsV2Argument[]
1729+
/**
1730+
* Opaque context set in the interactive canvas web app for all subsequent
1731+
* intents
1732+
*/
1733+
canvasState?: ApiClientObjectMap<any>
17291734
/**
17301735
* Indicates the user's intent. For the first conversation turn, the intent
17311736
* will refer to the triggering intent for the Action. For
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Copyright 2019 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+
17+
import * as Api from '../api/v2'
18+
import { JsonObject } from '../../../common'
19+
20+
export class Canvas {
21+
/**
22+
* Gets the canvas state
23+
*
24+
* Accessible using `conv.canvas.state`
25+
* @public
26+
*/
27+
state?: JsonObject
28+
29+
/** @hidden */
30+
constructor(user: Api.GoogleActionsV2Input) {
31+
this.state = user.canvasState
32+
}
33+
}

src/service/actionssdk/conversation/conversation.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { Input } from './input'
3939
import { JsonObject } from '../../../common'
4040
import { ServiceBaseApp, AppOptions } from '../../../assistant'
4141
import { OAuth2Client } from 'google-auth-library'
42+
import { Canvas } from './canvas'
4243

4344
/** @public */
4445
export type Intent =
@@ -222,6 +223,9 @@ export class Conversation<TUserStorage> {
222223
/** @public */
223224
device: Device
224225

226+
/** @public */
227+
canvas: Canvas
228+
225229
/**
226230
* Gets the unique conversation ID. It's a new ID for the initial query,
227231
* and stays the same until the end of the conversation.
@@ -328,6 +332,8 @@ export class Conversation<TUserStorage> {
328332

329333
this.device = new Device(this.request.device)
330334

335+
this.canvas = new Canvas(input)
336+
331337
this.id = conversation.conversationId!
332338

333339
this.type = conversation.type!

0 commit comments

Comments
 (0)