xref: /aosp_15_r20/external/googleapis/google/chat/v1/widgets.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.chat.v1;
18
19option csharp_namespace = "Google.Apps.Chat.V1";
20option go_package = "cloud.google.com/go/chat/apiv1/chatpb;chatpb";
21option java_multiple_files = true;
22option java_outer_classname = "WidgetsProto";
23option java_package = "com.google.chat.v1";
24option php_namespace = "Google\\Apps\\Chat\\V1";
25option ruby_package = "Google::Apps::Chat::V1";
26
27// A widget is a UI element that presents text and images.
28message WidgetMarkup {
29  // A paragraph of text. Formatted text supported. For more information
30  // about formatting text, see
31  // [Formatting text in Google Chat
32  // apps](https://developers.google.com/workspace/chat/format-messages#card-formatting)
33  // and
34  // [Formatting
35  // text in Google Workspace
36  // Add-ons](https://developers.google.com/apps-script/add-ons/concepts/widgets#text_formatting).
37  message TextParagraph {
38    string text = 1;
39  }
40
41  // The set of supported icons.
42  enum Icon {
43    ICON_UNSPECIFIED = 0;
44
45    AIRPLANE = 1;
46
47    BOOKMARK = 26;
48
49    BUS = 25;
50
51    CAR = 9;
52
53    CLOCK = 2;
54
55    CONFIRMATION_NUMBER_ICON = 12;
56
57    DOLLAR = 14;
58
59    DESCRIPTION = 27;
60
61    EMAIL = 10;
62
63    EVENT_PERFORMER = 20;
64
65    EVENT_SEAT = 21;
66
67    FLIGHT_ARRIVAL = 16;
68
69    FLIGHT_DEPARTURE = 15;
70
71    HOTEL = 6;
72
73    HOTEL_ROOM_TYPE = 17;
74
75    INVITE = 19;
76
77    MAP_PIN = 3;
78
79    MEMBERSHIP = 24;
80
81    MULTIPLE_PEOPLE = 18;
82
83    OFFER = 30;
84
85    PERSON = 11;
86
87    PHONE = 13;
88
89    RESTAURANT_ICON = 7;
90
91    SHOPPING_CART = 8;
92
93    STAR = 5;
94
95    STORE = 22;
96
97    TICKET = 4;
98
99    TRAIN = 23;
100
101    VIDEO_CAMERA = 28;
102
103    VIDEO_PLAY = 29;
104  }
105
106  // A button. Can be a text button or an image button.
107  message Button {
108    oneof type {
109      // A button with text and `onclick` action.
110      TextButton text_button = 1;
111
112      // A button with image and `onclick` action.
113      ImageButton image_button = 2;
114    }
115  }
116
117  // A button with text and `onclick` action.
118  message TextButton {
119    // The text of the button.
120    string text = 1;
121
122    // The `onclick` action of the button.
123    OnClick on_click = 2;
124  }
125
126  // A UI element contains a key (label) and a value (content). This
127  // element can also contain some actions such as `onclick` button.
128  message KeyValue {
129    // At least one of icons, `top_label` and `bottom_label` must be defined.
130    oneof icons {
131      // An enum value that's replaced by the Chat API with the
132      // corresponding icon image.
133      Icon icon = 1;
134
135      // The icon specified by a URL.
136      string icon_url = 2;
137    }
138
139    // The text of the top label. Formatted text supported. For more information
140    // about formatting text, see
141    // [Formatting text in Google Chat
142    // apps](https://developers.google.com/workspace/chat/format-messages#card-formatting)
143    // and
144    // [Formatting
145    // text in Google Workspace
146    // Add-ons](https://developers.google.com/apps-script/add-ons/concepts/widgets#text_formatting).
147    string top_label = 3;
148
149    // The text of the content. Formatted text supported and always required.
150    // For more information
151    // about formatting text, see
152    // [Formatting text in Google Chat
153    // apps](https://developers.google.com/workspace/chat/format-messages#card-formatting)
154    // and
155    // [Formatting
156    // text in Google Workspace
157    // Add-ons](https://developers.google.com/apps-script/add-ons/concepts/widgets#text_formatting).
158    string content = 4;
159
160    // If the content should be multiline.
161    bool content_multiline = 9;
162
163    // The text of the bottom label. Formatted text supported. For more
164    // information about formatting text, see [Formatting text in Google Chat
165    // apps](https://developers.google.com/workspace/chat/format-messages#card-formatting)
166    // and
167    // [Formatting
168    // text in Google Workspace
169    // Add-ons](https://developers.google.com/apps-script/add-ons/concepts/widgets#text_formatting).
170    string bottom_label = 5;
171
172    // The `onclick` action. Only the top label, bottom label, and content
173    // region are clickable.
174    OnClick on_click = 6;
175
176    // A control widget. You can set either `button` or `switch_widget`,
177    // but not both.
178    oneof control {
179      // A button that can be clicked to trigger an action.
180      Button button = 7;
181    }
182  }
183
184  // An image that's specified by a URL and can have an `onclick` action.
185  message Image {
186    // The URL of the image.
187    string image_url = 1;
188
189    // The `onclick` action.
190    OnClick on_click = 2;
191
192    // The aspect ratio of this image (width and height). This field lets you
193    // reserve the right height for the image while waiting for it to load.
194    // It's not meant to override the built-in aspect ratio of the image.
195    // If unset, the server fills it by prefetching the image.
196    double aspect_ratio = 3;
197  }
198
199  // An image button with an `onclick` action.
200  message ImageButton {
201    // The icon can be specified by an `Icon` `enum` or a URL.
202    oneof icons {
203      // The icon specified by an `enum` that indices to an icon provided by
204      // Chat API.
205      Icon icon = 1;
206
207      // The icon specified by a URL.
208      string icon_url = 3;
209    }
210
211    // The `onclick` action.
212    OnClick on_click = 2;
213
214    // The name of this `image_button` that's used for accessibility.
215    // Default value is provided if this name isn't specified.
216    string name = 4;
217  }
218
219  // An `onclick` action (for example, open a link).
220  message OnClick {
221    oneof data {
222      // A form action is triggered by this `onclick` action if specified.
223      FormAction action = 1;
224
225      // This `onclick` action triggers an open link action if specified.
226      OpenLink open_link = 2;
227    }
228  }
229
230  // A link that opens a new window.
231  message OpenLink {
232    // The URL to open.
233    string url = 1;
234  }
235
236  // A form action describes the behavior when the form is submitted.
237  // For example, you can invoke Apps Script to handle the form.
238  message FormAction {
239    // List of string parameters to supply when the action method is invoked.
240    // For example, consider three snooze buttons: snooze now, snooze one day,
241    // snooze next week. You might use `action method = snooze()`, passing the
242    // snooze type and snooze time in the list of string parameters.
243    message ActionParameter {
244      // The name of the parameter for the action script.
245      string key = 1;
246
247      // The value of the parameter.
248      string value = 2;
249    }
250
251    // The method name is used to identify which part of the form triggered the
252    // form submission. This information is echoed back to the Chat app as part
253    // of the card click event. You can use the same method name for several
254    // elements that trigger a common behavior.
255    string action_method_name = 1;
256
257    // List of action parameters.
258    repeated ActionParameter parameters = 2;
259  }
260
261  // A `WidgetMarkup` can only have one of the following items. You can use
262  // multiple `WidgetMarkup` fields to display more items.
263  oneof data {
264    // Display a text paragraph in this widget.
265    TextParagraph text_paragraph = 1;
266
267    // Display an image in this widget.
268    Image image = 2;
269
270    // Display a key value item in this widget.
271    KeyValue key_value = 3;
272  }
273
274  // A list of buttons. Buttons is also `oneof data` and only one of these
275  // fields should be set.
276  repeated Button buttons = 6;
277}
278