From 8e39e1ef5482735fbaaed3be74ee472cf44cd941 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Date: Tue, 20 Jul 2021 07:07:10 +0000 Subject: [PATCH] feat(chat): update the api #### chat:v1 The following keys were deleted: - schemas.CardWithId (Total Keys: 4) - schemas.Color (Total Keys: 10) - schemas.GoogleAppsCardV1Action (Total Keys: 11) - schemas.GoogleAppsCardV1BorderStyle (Total Keys: 6) - schemas.GoogleAppsCardV1Button (Total Keys: 12) - schemas.GoogleAppsCardV1Card (Total Keys: 23) - schemas.GoogleAppsCardV1DateTimePicker (Total Keys: 10) - schemas.GoogleAppsCardV1DecoratedText (Total Keys: 12) - schemas.GoogleAppsCardV1Divider (Total Keys: 2) - schemas.GoogleAppsCardV1Grid (Total Keys: 14) - schemas.GoogleAppsCardV1Icon (Total Keys: 5) - schemas.GoogleAppsCardV1Image (Total Keys: 15) - schemas.GoogleAppsCardV1OnClick (Total Keys: 6) - schemas.GoogleAppsCardV1OpenLink (Total Keys: 4) - schemas.GoogleAppsCardV1Section (Total Keys: 8) - schemas.GoogleAppsCardV1SelectionInput (Total Keys: 8) - schemas.GoogleAppsCardV1SelectionItem (Total Keys: 5) - schemas.GoogleAppsCardV1SuggestionItem (Total Keys: 3) - schemas.GoogleAppsCardV1Suggestions (Total Keys: 4) - schemas.GoogleAppsCardV1SwitchControl (Total Keys: 7) - schemas.GoogleAppsCardV1TextInput (Total Keys: 10) - schemas.GoogleAppsCardV1TextParagraph (Total Keys: 3) - schemas.GoogleAppsCardV1Widget (Total Keys: 12) - schemas.Message.properties.cardsV2 (Total Keys: 2) --- docs/dyn/chat_v1.dms.conversations.html | 1044 ------- docs/dyn/chat_v1.dms.html | 2088 ------------- docs/dyn/chat_v1.rooms.conversations.html | 1044 ------- docs/dyn/chat_v1.rooms.html | 2088 ------------- docs/dyn/chat_v1.spaces.html | 1044 ------- docs/dyn/chat_v1.spaces.messages.html | 2610 ----------------- .../discovery_cache/documents/chat.v1.json | 885 +----- 7 files changed, 1 insertion(+), 10802 deletions(-) diff --git a/docs/dyn/chat_v1.dms.conversations.html b/docs/dyn/chat_v1.dms.conversations.html index 2b48a07b493..7ea2a8c123a 100644 --- a/docs/dyn/chat_v1.dms.conversations.html +++ b/docs/dyn/chat_v1.dms.conversations.html @@ -307,528 +307,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", @@ -1077,528 +555,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", diff --git a/docs/dyn/chat_v1.dms.html b/docs/dyn/chat_v1.dms.html index eb1e4af391a..060f7d463f1 100644 --- a/docs/dyn/chat_v1.dms.html +++ b/docs/dyn/chat_v1.dms.html @@ -315,528 +315,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", @@ -1085,528 +563,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", @@ -1856,528 +812,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", @@ -2626,528 +1060,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", diff --git a/docs/dyn/chat_v1.rooms.conversations.html b/docs/dyn/chat_v1.rooms.conversations.html index 83331799364..835c91525e1 100644 --- a/docs/dyn/chat_v1.rooms.conversations.html +++ b/docs/dyn/chat_v1.rooms.conversations.html @@ -307,528 +307,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", @@ -1077,528 +555,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", diff --git a/docs/dyn/chat_v1.rooms.html b/docs/dyn/chat_v1.rooms.html index 3df108313df..d10eab55270 100644 --- a/docs/dyn/chat_v1.rooms.html +++ b/docs/dyn/chat_v1.rooms.html @@ -315,528 +315,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", @@ -1085,528 +563,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", @@ -1856,528 +812,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", @@ -2626,528 +1060,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", diff --git a/docs/dyn/chat_v1.spaces.html b/docs/dyn/chat_v1.spaces.html index c865391b469..d987d9dcce3 100644 --- a/docs/dyn/chat_v1.spaces.html +++ b/docs/dyn/chat_v1.spaces.html @@ -392,528 +392,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", @@ -1162,528 +640,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", diff --git a/docs/dyn/chat_v1.spaces.messages.html b/docs/dyn/chat_v1.spaces.messages.html index a247ed3eb8b..bd701f548ef 100644 --- a/docs/dyn/chat_v1.spaces.messages.html +++ b/docs/dyn/chat_v1.spaces.messages.html @@ -321,528 +321,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", @@ -1091,528 +569,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", @@ -1885,528 +841,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", @@ -2656,528 +1090,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", @@ -3426,528 +1338,6 @@

Method Details

], }, ], - "cardsV2": [ # Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs. - { # Widgets for chatbots to specify. - "card": { # A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { "header": { "title": "Heba Salam", "subtitle": "Software Engineer", "imageStyle": "ImageStyle.AVATAR", "imageUrl": "https://example.com/heba_salam.png", "imageAltText": "Avatar for Heba Salam" }, "sections" : [ { "header": "Contact Info", "widgets": [ { "decorated_text": { "icon": { "knownIcon": "EMAIL" }, "content": "heba.salam@example.com" } }, { "decoratedText": { "icon": { "knownIcon": "PERSON" }, "content": "Online" } }, { "decoratedText": { "icon": { "knownIcon": "PHONE" }, "content": "+1 (555) 555-1234" } }, { "buttons": [ { "textButton": { "text": "Share", }, "onClick": { "openLink": { "url": "https://example.com/share" } } }, { "textButton": { "text": "Edit", }, "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT" } ], "loadIndicator": "LoadIndicator.SPINNER" } } } ] } ], "collapsible": true, "uncollapsibleWidgetsCount": 3 } ], "cardActions": [ { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ], "name": "contact-card-K3wB6arF2H9L" } ``` # Card proto that allows chatbots to specify UI elements and editable widgets. - "cardActions": [ # The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` "card_actions": [ { "actionLabel": "Setting", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] ``` - { # A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser. - "actionLabel": "A String", # The label that displays as the action menu item. - "onClick": { # The onclick action for this action item. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - ], - "displayStyle": "A String", # The display style for peekCardHeader. - "fixedFooter": { # A persistent (sticky) footer that is added to the bottom of the card. # The fixed footer shown at the bottom of this card. - "primaryButton": { # A button. Can be a text button or an image button. # The primary button of the fixed footer. The button must be a text button with text and color set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "secondaryButton": { # A button. Can be a text button or an image button. # The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - }, - "header": { # The header of the card. A header usually contains a title and an image. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "name": "A String", # Name of the card, which is used as a identifier for the card in card navigation. - "peekCardHeader": { # When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards. - "imageAltText": "A String", # The alternative text of this image which is used for accessibility. - "imageType": "A String", # The image's type. - "imageUrl": "A String", # The URL of the image in the card header. - "subtitle": "A String", # The subtitle of the card header. - "title": "A String", # The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines. - }, - "sections": [ # Sections are separated by a line divider. - { # A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float. - "collapsible": True or False, # Indicates whether this section is collapsible. If a section is collapsible, the description must be given. - "header": "A String", # The header of the section. Formatted text is supported. - "uncollapsibleWidgetsCount": 42, # The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`. - "widgets": [ # A section must contain at least 1 widget. - { # A widget is a UI element that presents texts, images, etc. - "buttonList": { # A list of buttons layed out horizontally. # A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ "button": { "text": "Edit", "Color": { "Red": 255 "Green": 255 "Blue": 255 } "disabled": true }, "button": { "icon": { "knownIcon": "INVITE" "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } }, ] } ``` - "buttons": [ - { # A button. Can be a text button or an image button. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - ], - }, - "dateTimePicker": { # The widget that lets users to specify a date and time. # Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` "date_time_picker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DateTimePickerType.DATE_AND_TIME", "valueMsEpoch": "796435200000" } ``` - "label": "A String", # The label for the field that displays to the user. - "name": "A String", # The name of the text input that's used in formInput, and uniquely identifies this input. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "timezoneOffsetDate": 42, # The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side. - "type": "A String", # The type of the date/time picker. - "valueMsEpoch": "A String", # The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am. - }, - "decoratedText": { # A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text. # Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "content": "heba.salam@example.com", "bottomLabel": "This is a new Email address!", "switchWidget": { "name": "has_send_welcome_email_to_heba_salam", "selected": false, "controlType": "ControlType.CHECKBOX" } } ``` - "bottomLabel": "A String", # The formatted text label that shows below the main text. - "button": { # A button. Can be a text button or an image button. # A button that can be clicked to trigger an action. - "altText": "A String", # The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead. - "color": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # If set, the button is filled with a solid background. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "disabled": True or False, # If true, the button is displayed in a disabled state and doesn't respond to user actions. - "icon": { # The icon image. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # The action to perform when the button is clicked. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "text": "A String", # The text of the button. - }, - "endIcon": { # An icon displayed after the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "icon": { # Deprecated in favor of start_icon. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "onClick": { # Only the top and bottom label and content region are clickable. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "startIcon": { # The icon displayed in front of the text. - "altText": "A String", # The description of the icon, used for accessibility. The default value is provided if you don't specify one. - "iconUrl": "A String", # The icon specified by a URL. - "imageType": "A String", # The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon. - "knownIcon": "A String", # The icon specified by the string name of a list of known icons - }, - "switchControl": { # A switch widget can be clicked to change its state or trigger an action. - "controlType": "A String", # The control type, either switch or checkbox. - "name": "A String", # The name of the switch widget that's used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The action when the switch state is changed. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "selected": True or False, # If the switch is selected. - "value": "A String", # The value is what is passed back in the callback. - }, - "text": "A String", # Required. The main widget formatted text. See Text formatting for details. - "topLabel": "A String", # The formatted text label that shows above the main text. - "wrapText": True or False, # The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated. - }, - "divider": { # A divider that appears in between widgets. # Displays a divider. For example, the following JSON creates a divider: ``` "divider": { } ``` - }, - "grid": { # Represents a Grid widget that displays items in a configurable grid layout. # Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "numColumns": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4.0 }, "items": [ "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" ], "onClick": { "openLink": { "url":"https://www.example.com" } } } ``` - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to each grid item. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "columnCount": 42, # The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). - "items": [ # The items to display in the grid. - { # Represents a single item in the grid layout. - "id": "A String", # A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters. - "image": { # The image that displays in the grid item. - "altText": "A String", # The accessibility label for the image. - "borderStyle": { # Represents the complete border style applied to widgets. # The border style to apply to the image. - "cornerRadius": 42, # The corner radius for the border. - "strokeColor": { # Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ... # The colors to use when the type is `BORDER_TYPE_STROKE`. - "alpha": 3.14, # The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). - "blue": 3.14, # The amount of blue in the color as a value in the interval [0, 1]. - "green": 3.14, # The amount of green in the color as a value in the interval [0, 1]. - "red": 3.14, # The amount of red in the color as a value in the interval [0, 1]. - }, - "type": "A String", # The border type. - }, - "cropStyle": { # Represents the crop style applied to an image. # The crop style to apply to the image. - "aspectRatio": 3.14, # The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`. - "type": "A String", # The crop type. - }, - "imageUri": "A String", # The image URL. - }, - "layout": "A String", # The layout to use for the grid item. - "subtitle": "A String", # The grid item's subtitle. - "textAlignment": "A String", # The horizontal alignment of the grid item's text. - "title": "A String", # The grid item's title. - }, - ], - "onClick": { # This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - "title": "A String", # The text that displays in the grid header. - }, - "horizontalAlignment": "A String", # The horizontal alignment of this widget. - "image": { # An image that is specified by a URL and can have an onClick action. # Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://example.com/heba_salam.png" "altText": "Avatar for Heba Salam" } ``` - "altText": "A String", # The alternative text of this image, used for accessibility. - "imageUrl": "A String", # An image URL. - "onClick": { - "action": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, an action is triggered by this onClick. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "card": # Object with schema name: GoogleAppsCardV1Card # A new card is pushed to the card stack after clicking if specified. - "openDynamicLinkAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "openLink": { # If specified, this onClick triggers an open link action. - "onClose": "A String", - "openAs": "A String", - "url": "A String", # The URL to open. - }, - }, - }, - "selectionInput": { # A widget that creates a UI item (for example, a drop-down list) with options for users to select. # Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` "switchControl": { "name": "size", "label": "Size" "type": "SelectionType.DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ``` - "items": [ - { # The item in the switch control. A radio button, at most one of the items is selected. - "selected": True or False, # If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored. - "text": "A String", # The text to be displayed. - "value": "A String", # The value associated with this item. The client should use this as a form input value. - }, - ], - "label": "A String", # The label displayed ahead of the switch control. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", - }, - "textInput": { # A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions. # Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ``` - "autoCompleteAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "hintText": "A String", # The hint text. - "initialSuggestions": { # A container wrapping elements necessary for showing suggestion items used in text input autocomplete. # The initial suggestions made before any user input. - "items": [ # A list of suggestions items which will be used in are used in autocomplete. - { # A suggestion item. Only supports text for now. - "text": "A String", - }, - ], - }, - "label": "A String", # At least one of label and hintText must be specified. - "name": "A String", # The name of the text input which is used in formInput. - "onChangeAction": { # An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. # The onChange action, for example, invoke a function. - "function": "A String", # Apps Script function to invoke when the containing element is clicked/activated. - "loadIndicator": "A String", - "parameters": [ # List of action parameters. - { # List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters. - "key": "A String", # The name of the parameter for the action script. - "value": "A String", # The value of the parameter. - }, - ], - "persistValues": True or False, # Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed. - }, - "type": "A String", # The style of the text, for example, a single line or multiple lines. - "value": "A String", # The default value when there is no input from the user. - }, - "textParagraph": { # A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting") for details. # Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ``` - "text": "A String", # The text that's shown in the widget. - }, - }, - ], - }, - ], - }, - "cardId": "A String", # Chatbot-specified identifier for this widget. Scoped within a message. - }, - ], "createTime": "A String", # Output only. The time at which the message was created in Hangouts Chat server. "fallbackText": "A String", # A plain-text description of the message's cards, used when the actual cards cannot be displayed (e.g. mobile notifications). "name": "A String", diff --git a/googleapiclient/discovery_cache/documents/chat.v1.json b/googleapiclient/discovery_cache/documents/chat.v1.json index 890f8fbea15..3c8d04ca994 100644 --- a/googleapiclient/discovery_cache/documents/chat.v1.json +++ b/googleapiclient/discovery_cache/documents/chat.v1.json @@ -601,7 +601,7 @@ } } }, - "revision": "20210630", + "revision": "20210709", "rootUrl": "https://chat.googleapis.com/", "schemas": { "ActionParameter": { @@ -836,48 +836,6 @@ }, "type": "object" }, - "CardWithId": { - "description": "Widgets for chatbots to specify.", - "id": "CardWithId", - "properties": { - "card": { - "$ref": "GoogleAppsCardV1Card", - "description": "Card proto that allows chatbots to specify UI elements and editable widgets." - }, - "cardId": { - "description": "Chatbot-specified identifier for this widget. Scoped within a message.", - "type": "string" - } - }, - "type": "object" - }, - "Color": { - "description": "Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ...", - "id": "Color", - "properties": { - "alpha": { - "description": "The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0).", - "format": "float", - "type": "number" - }, - "blue": { - "description": "The amount of blue in the color as a value in the interval [0, 1].", - "format": "float", - "type": "number" - }, - "green": { - "description": "The amount of green in the color as a value in the interval [0, 1].", - "format": "float", - "type": "number" - }, - "red": { - "description": "The amount of red in the color as a value in the interval [0, 1].", - "format": "float", - "type": "number" - } - }, - "type": "object" - }, "DeprecatedEvent": { "description": "Google Chat events.", "id": "DeprecatedEvent", @@ -971,840 +929,6 @@ }, "type": "object" }, - "GoogleAppsCardV1Action": { - "description": "An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form.", - "id": "GoogleAppsCardV1Action", - "properties": { - "function": { - "description": "Apps Script function to invoke when the containing element is clicked/activated.", - "type": "string" - }, - "loadIndicator": { - "enum": [ - "SPINNER", - "NONE" - ], - "enumDescriptions": [ - "Displays a spinner to indicate that content is loading.", - "Nothing is displayed." - ], - "type": "string" - }, - "parameters": { - "description": "List of action parameters.", - "items": { - "$ref": "GoogleAppsCardV1ActionParameter" - }, - "type": "array" - }, - "persistValues": { - "description": "Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. When using [LoadIndicator.NONE](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for actions, `persist_values` = `true`is recommended, as it ensures that any changes made by the user after form or on change actions are sent to the server are not overwritten by the response. If `false`, the form values are cleared when the action is triggered. When `persist_values` is set to `false`, it is strongly recommended that the card use [LoadIndicator.SPINNER](workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) for all actions, as this locks the UI to ensure no changes are made by the user while the action is being processed.", - "type": "boolean" - } - }, - "type": "object" - }, - "GoogleAppsCardV1ActionParameter": { - "description": "List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters.", - "id": "GoogleAppsCardV1ActionParameter", - "properties": { - "key": { - "description": "The name of the parameter for the action script.", - "type": "string" - }, - "value": { - "description": "The value of the parameter.", - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1BorderStyle": { - "description": "Represents the complete border style applied to widgets.", - "id": "GoogleAppsCardV1BorderStyle", - "properties": { - "cornerRadius": { - "description": "The corner radius for the border.", - "format": "int32", - "type": "integer" - }, - "strokeColor": { - "$ref": "Color", - "description": "The colors to use when the type is `BORDER_TYPE_STROKE`." - }, - "type": { - "description": "The border type.", - "enum": [ - "BORDER_TYPE_UNSPECIFIED", - "NO_BORDER", - "STROKE" - ], - "enumDescriptions": [ - "No value specified.", - "No border.", - "Outline." - ], - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1Button": { - "description": "A button. Can be a text button or an image button.", - "id": "GoogleAppsCardV1Button", - "properties": { - "altText": { - "description": "The alternative text used for accessibility. Has no effect when an icon is set; use `icon.alt_text` instead.", - "type": "string" - }, - "color": { - "$ref": "Color", - "description": "If set, the button is filled with a solid background." - }, - "disabled": { - "description": "If true, the button is displayed in a disabled state and doesn't respond to user actions.", - "type": "boolean" - }, - "icon": { - "$ref": "GoogleAppsCardV1Icon", - "description": "The icon image." - }, - "onClick": { - "$ref": "GoogleAppsCardV1OnClick", - "description": "The action to perform when the button is clicked." - }, - "text": { - "description": "The text of the button.", - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1ButtonList": { - "description": "A list of buttons layed out horizontally.", - "id": "GoogleAppsCardV1ButtonList", - "properties": { - "buttons": { - "items": { - "$ref": "GoogleAppsCardV1Button" - }, - "type": "array" - } - }, - "type": "object" - }, - "GoogleAppsCardV1Card": { - "description": "A card is a UI element that can contain UI widgets such as text and images. For more information, see Cards . For example, the following JSON creates a card that has a header with the name, position, icons, and link for a contact, followed by a section with contact information like email and phone number. ``` { \"header\": { \"title\": \"Heba Salam\", \"subtitle\": \"Software Engineer\", \"imageStyle\": \"ImageStyle.AVATAR\", \"imageUrl\": \"https://example.com/heba_salam.png\", \"imageAltText\": \"Avatar for Heba Salam\" }, \"sections\" : [ { \"header\": \"Contact Info\", \"widgets\": [ { \"decorated_text\": { \"icon\": { \"knownIcon\": \"EMAIL\" }, \"content\": \"heba.salam@example.com\" } }, { \"decoratedText\": { \"icon\": { \"knownIcon\": \"PERSON\" }, \"content\": \"Online\" } }, { \"decoratedText\": { \"icon\": { \"knownIcon\": \"PHONE\" }, \"content\": \"+1 (555) 555-1234\" } }, { \"buttons\": [ { \"textButton\": { \"text\": \"Share\", }, \"onClick\": { \"openLink\": { \"url\": \"https://example.com/share\" } } }, { \"textButton\": { \"text\": \"Edit\", }, \"onClick\": { \"action\": { \"function\": \"goToView\", \"parameters\": [ { \"key\": \"viewType\", \"value\": \"EDIT\" } ], \"loadIndicator\": \"LoadIndicator.SPINNER\" } } } ] } ], \"collapsible\": true, \"uncollapsibleWidgetsCount\": 3 } ], \"cardActions\": [ { \"actionLabel\": \"Send Feedback\", \"onClick\": { \"openLink\": { \"url\": \"https://example.com/feedback\" } } } ], \"name\": \"contact-card-K3wB6arF2H9L\" } ```", - "id": "GoogleAppsCardV1Card", - "properties": { - "cardActions": { - "description": "The actions of this card. They are added to a card's generated toolbar menu. For example, the following JSON constructs a card action menu with Settings and Send Feedback options: ``` \"card_actions\": [ { \"actionLabel\": \"Setting\", \"onClick\": { \"action\": { \"functionName\": \"goToView\", \"parameters\": [ { \"key\": \"viewType\", \"value\": \"SETTING\" } ], \"loadIndicator\": \"LoadIndicator.SPINNER\" } } }, { \"actionLabel\": \"Send Feedback\", \"onClick\": { \"openLink\": { \"url\": \"https://example.com/feedback\" } } } ] ```", - "items": { - "$ref": "GoogleAppsCardV1CardAction" - }, - "type": "array" - }, - "displayStyle": { - "description": "The display style for peekCardHeader.", - "enum": [ - "DISPLAY_STYLE_UNSPECIFIED", - "PEEK", - "REPLACE" - ], - "enumDescriptions": [ - "", - "The header of the card appears at the bottom of the sidebar, partially covering the current top card of the stack. Clicking the header pops the card into the card stack. If the card has no header, a generated header is used instead.", - "The card is shown by replacing the view of the top card in the card stack." - ], - "type": "string" - }, - "fixedFooter": { - "$ref": "GoogleAppsCardV1CardFixedFooter", - "description": "The fixed footer shown at the bottom of this card." - }, - "header": { - "$ref": "GoogleAppsCardV1CardHeader", - "description": "The header of the card. A header usually contains a title and an image." - }, - "name": { - "description": "Name of the card, which is used as a identifier for the card in card navigation.", - "type": "string" - }, - "peekCardHeader": { - "$ref": "GoogleAppsCardV1CardHeader", - "description": "When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards." - }, - "sections": { - "description": "Sections are separated by a line divider.", - "items": { - "$ref": "GoogleAppsCardV1Section" - }, - "type": "array" - } - }, - "type": "object" - }, - "GoogleAppsCardV1CardAction": { - "description": "A card action is the action associated with the card. For example, an invoice card might include actions such as delete invoice, email invoice, or open the invoice in a browser.", - "id": "GoogleAppsCardV1CardAction", - "properties": { - "actionLabel": { - "description": "The label that displays as the action menu item.", - "type": "string" - }, - "onClick": { - "$ref": "GoogleAppsCardV1OnClick", - "description": "The onclick action for this action item." - } - }, - "type": "object" - }, - "GoogleAppsCardV1CardFixedFooter": { - "description": "A persistent (sticky) footer that is added to the bottom of the card.", - "id": "GoogleAppsCardV1CardFixedFooter", - "properties": { - "primaryButton": { - "$ref": "GoogleAppsCardV1Button", - "description": "The primary button of the fixed footer. The button must be a text button with text and color set." - }, - "secondaryButton": { - "$ref": "GoogleAppsCardV1Button", - "description": "The secondary button of the fixed footer. The button must be a text button with text and color set. `primaryButton` must be set if `secondaryButton` is set." - } - }, - "type": "object" - }, - "GoogleAppsCardV1CardHeader": { - "id": "GoogleAppsCardV1CardHeader", - "properties": { - "imageAltText": { - "description": "The alternative text of this image which is used for accessibility.", - "type": "string" - }, - "imageType": { - "description": "The image's type.", - "enum": [ - "SQUARE", - "CIRCLE" - ], - "enumDescriptions": [ - "Applies no cropping to the image.", - "Applies a circular mask to the image." - ], - "type": "string" - }, - "imageUrl": { - "description": "The URL of the image in the card header.", - "type": "string" - }, - "subtitle": { - "description": "The subtitle of the card header.", - "type": "string" - }, - "title": { - "description": "The title of the card header. The title must be specified. The header has a fixed height: if both a title and subtitle are specified, each takes up one line. If only the title is specified, it takes up both lines.", - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1DateTimePicker": { - "description": "The widget that lets users to specify a date and time.", - "id": "GoogleAppsCardV1DateTimePicker", - "properties": { - "label": { - "description": "The label for the field that displays to the user.", - "type": "string" - }, - "name": { - "description": "The name of the text input that's used in formInput, and uniquely identifies this input.", - "type": "string" - }, - "onChangeAction": { - "$ref": "GoogleAppsCardV1Action", - "description": "Triggered when the user clicks Save or Clear from the date/time picker dialog. This is only triggered if the value changed as a result of the Save/Clear operation." - }, - "timezoneOffsetDate": { - "description": "The number representing the time zone offset from UTC, in minutes. If set, the `value_ms_epoch` is displayed in the specified time zone. If not set, it uses the user's time zone setting on the client side.", - "format": "int32", - "type": "integer" - }, - "type": { - "description": "The type of the date/time picker.", - "enum": [ - "DATE_AND_TIME", - "DATE_ONLY", - "TIME_ONLY" - ], - "enumDescriptions": [ - "The user can select a date and time.", - "The user can only select a date.", - "The user can only select a time." - ], - "type": "string" - }, - "valueMsEpoch": { - "description": "The value to display as the default value before user input or previous user input. It is represented in milliseconds (Epoch time). For `DATE_AND_TIME` type, the full epoch value is used. For `DATE_ONLY` type, only date of the epoch time is used. For `TIME_ONLY` type, only time of the epoch time is used. For example, you can set epoch time to `3 * 60 * 60 * 1000` to represent 3am.", - "format": "int64", - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1DecoratedText": { - "description": "A widget that displays text with optional decorations such as a label above or below the text, an icon in front of the text, a selection widget or a button after the text.", - "id": "GoogleAppsCardV1DecoratedText", - "properties": { - "bottomLabel": { - "description": "The formatted text label that shows below the main text.", - "type": "string" - }, - "button": { - "$ref": "GoogleAppsCardV1Button", - "description": "A button that can be clicked to trigger an action." - }, - "endIcon": { - "$ref": "GoogleAppsCardV1Icon", - "description": "An icon displayed after the text." - }, - "icon": { - "$ref": "GoogleAppsCardV1Icon", - "description": "Deprecated in favor of start_icon." - }, - "onClick": { - "$ref": "GoogleAppsCardV1OnClick", - "description": "Only the top and bottom label and content region are clickable." - }, - "startIcon": { - "$ref": "GoogleAppsCardV1Icon", - "description": "The icon displayed in front of the text." - }, - "switchControl": { - "$ref": "GoogleAppsCardV1SwitchControl", - "description": "A switch widget can be clicked to change its state or trigger an action." - }, - "text": { - "description": "Required. The main widget formatted text. See Text formatting for details.", - "type": "string" - }, - "topLabel": { - "description": "The formatted text label that shows above the main text.", - "type": "string" - }, - "wrapText": { - "description": "The wrap text setting. If `true`, the text is wrapped and displayed in multiline. Otherwise, the text is truncated.", - "type": "boolean" - } - }, - "type": "object" - }, - "GoogleAppsCardV1Divider": { - "description": "A divider that appears in between widgets.", - "id": "GoogleAppsCardV1Divider", - "properties": {}, - "type": "object" - }, - "GoogleAppsCardV1Grid": { - "description": "Represents a Grid widget that displays items in a configurable grid layout.", - "id": "GoogleAppsCardV1Grid", - "properties": { - "borderStyle": { - "$ref": "GoogleAppsCardV1BorderStyle", - "description": "The border style to apply to each grid item." - }, - "columnCount": { - "description": "The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion).", - "format": "int32", - "type": "integer" - }, - "items": { - "description": "The items to display in the grid.", - "items": { - "$ref": "GoogleAppsCardV1GridItem" - }, - "type": "array" - }, - "onClick": { - "$ref": "GoogleAppsCardV1OnClick", - "description": "This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters." - }, - "title": { - "description": "The text that displays in the grid header.", - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1GridItem": { - "description": "Represents a single item in the grid layout.", - "id": "GoogleAppsCardV1GridItem", - "properties": { - "id": { - "description": "A user-specified identifier for this grid item. This identifier is returned in the parent Grid's onClick callback parameters.", - "type": "string" - }, - "image": { - "$ref": "GoogleAppsCardV1ImageComponent", - "description": "The image that displays in the grid item." - }, - "layout": { - "description": "The layout to use for the grid item.", - "enum": [ - "GRID_ITEM_LAYOUT_UNSPECIFIED", - "TEXT_BELOW", - "TEXT_ABOVE" - ], - "enumDescriptions": [ - "No layout specified.", - "The title and subtitle are shown below the grid item's image.", - "The title and subtitle are shown above the grid item's image." - ], - "type": "string" - }, - "subtitle": { - "description": "The grid item's subtitle.", - "type": "string" - }, - "textAlignment": { - "description": "The horizontal alignment of the grid item's text.", - "enum": [ - "HORIZONTAL_ALIGNMENT_UNSPECIFIED", - "START", - "CENTER", - "END" - ], - "enumDescriptions": [ - "Unspecified alignment.", - "Alignment to the start position.", - "Alignment to the center position.", - "Alignment to the end position." - ], - "type": "string" - }, - "title": { - "description": "The grid item's title.", - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1Icon": { - "id": "GoogleAppsCardV1Icon", - "properties": { - "altText": { - "description": "The description of the icon, used for accessibility. The default value is provided if you don't specify one.", - "type": "string" - }, - "iconUrl": { - "description": "The icon specified by a URL.", - "type": "string" - }, - "imageType": { - "description": "The crop style applied to the image. In some cases, applying a `CIRCLE` crop causes the image to be drawn larger than a standard icon.", - "enum": [ - "SQUARE", - "CIRCLE" - ], - "enumDescriptions": [ - "Applies no cropping to the image.", - "Applies a circular mask to the image." - ], - "type": "string" - }, - "knownIcon": { - "description": "The icon specified by the string name of a list of known icons", - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1Image": { - "description": "An image that is specified by a URL and can have an onClick action.", - "id": "GoogleAppsCardV1Image", - "properties": { - "altText": { - "description": "The alternative text of this image, used for accessibility.", - "type": "string" - }, - "imageUrl": { - "description": "An image URL.", - "type": "string" - }, - "onClick": { - "$ref": "GoogleAppsCardV1OnClick" - } - }, - "type": "object" - }, - "GoogleAppsCardV1ImageComponent": { - "id": "GoogleAppsCardV1ImageComponent", - "properties": { - "altText": { - "description": "The accessibility label for the image.", - "type": "string" - }, - "borderStyle": { - "$ref": "GoogleAppsCardV1BorderStyle", - "description": "The border style to apply to the image." - }, - "cropStyle": { - "$ref": "GoogleAppsCardV1ImageCropStyle", - "description": "The crop style to apply to the image." - }, - "imageUri": { - "description": "The image URL.", - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1ImageCropStyle": { - "description": "Represents the crop style applied to an image.", - "id": "GoogleAppsCardV1ImageCropStyle", - "properties": { - "aspectRatio": { - "description": "The aspect ratio to use if the crop type is `RECTANGLE_CUSTOM`.", - "format": "double", - "type": "number" - }, - "type": { - "description": "The crop type.", - "enum": [ - "IMAGE_CROP_TYPE_UNSPECIFIED", - "SQUARE", - "CIRCLE", - "RECTANGLE_CUSTOM", - "RECTANGLE_4_3" - ], - "enumDescriptions": [ - "No value specified.", - "Applies a square crop.", - "Applies a circular crop.", - "Applies a rectangular crop with a custom aspect ratio.", - "Applies a rectangular crop with a 4:3 aspect ratio." - ], - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1OnClick": { - "id": "GoogleAppsCardV1OnClick", - "properties": { - "action": { - "$ref": "GoogleAppsCardV1Action", - "description": "If specified, an action is triggered by this onClick." - }, - "card": { - "$ref": "GoogleAppsCardV1Card", - "description": "A new card is pushed to the card stack after clicking if specified." - }, - "openDynamicLinkAction": { - "$ref": "GoogleAppsCardV1Action", - "description": "An add-on triggers this action when the action needs to open a link. This differs from the open_link above in that this needs to talk to server to get the link. Thus some preparation work is required for web client to do before the open link action response comes back." - }, - "openLink": { - "$ref": "GoogleAppsCardV1OpenLink", - "description": "If specified, this onClick triggers an open link action." - } - }, - "type": "object" - }, - "GoogleAppsCardV1OpenLink": { - "id": "GoogleAppsCardV1OpenLink", - "properties": { - "onClose": { - "enum": [ - "NOTHING", - "RELOAD" - ], - "enumDescriptions": [ - "Doesn\u2019t reload the card after the child window closes. Reloads the card after the child window closes. If used in conjunction with [OpenAs.OVERLAY](/workspace/add-ons/reference/rpc/google.apps.card.v1#openas), the child window acts as a modal dialog and the main card is blocked until the child window closes.", - "" - ], - "type": "string" - }, - "openAs": { - "enum": [ - "FULL_SIZE", - "OVERLAY" - ], - "enumDescriptions": [ - "The link opens as a full size window (if that's the frame used by the client.", - "The link opens as an overlay, such as a pop-up." - ], - "type": "string" - }, - "url": { - "description": "The URL to open.", - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1Section": { - "description": "A section contains a collection of widgets that are rendered vertically in the order that they are specified. Across all platforms, cards have a narrow fixed width, so there is currently no need for layout properties, for example, float.", - "id": "GoogleAppsCardV1Section", - "properties": { - "collapsible": { - "description": "Indicates whether this section is collapsible. If a section is collapsible, the description must be given.", - "type": "boolean" - }, - "header": { - "description": "The header of the section. Formatted text is supported.", - "type": "string" - }, - "uncollapsibleWidgetsCount": { - "description": "The number of uncollapsible widgets. For example, when a section contains five widgets and the `numUncollapsibleWidget` is set to `2`, the first two widgets are always shown and the last three are collapsed as default. The `numUncollapsibleWidget` is taken into account only when collapsible is set to `true`.", - "format": "int32", - "type": "integer" - }, - "widgets": { - "description": "A section must contain at least 1 widget.", - "items": { - "$ref": "GoogleAppsCardV1Widget" - }, - "type": "array" - } - }, - "type": "object" - }, - "GoogleAppsCardV1SelectionInput": { - "description": "A widget that creates a UI item (for example, a drop-down list) with options for users to select.", - "id": "GoogleAppsCardV1SelectionInput", - "properties": { - "items": { - "items": { - "$ref": "GoogleAppsCardV1SelectionItem" - }, - "type": "array" - }, - "label": { - "description": "The label displayed ahead of the switch control.", - "type": "string" - }, - "name": { - "description": "The name of the text input which is used in formInput.", - "type": "string" - }, - "onChangeAction": { - "$ref": "GoogleAppsCardV1Action", - "description": "If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button." - }, - "type": { - "enum": [ - "CHECK_BOX", - "RADIO_BUTTON", - "SWITCH", - "DROPDOWN" - ], - "enumDescriptions": [ - "The selection type is a checkbox.", - "The selection type is a radio button.", - "The selection type is a switch.", - "The selection type is a dropdown." - ], - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1SelectionItem": { - "description": "The item in the switch control. A radio button, at most one of the items is selected.", - "id": "GoogleAppsCardV1SelectionItem", - "properties": { - "selected": { - "description": "If more than one item is selected for `RADIO_BUTTON` and `DROPDOWN`, the first selected item is treated as selected and the ones after are ignored.", - "type": "boolean" - }, - "text": { - "description": "The text to be displayed.", - "type": "string" - }, - "value": { - "description": "The value associated with this item. The client should use this as a form input value.", - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1SuggestionItem": { - "description": "A suggestion item. Only supports text for now.", - "id": "GoogleAppsCardV1SuggestionItem", - "properties": { - "text": { - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1Suggestions": { - "description": "A container wrapping elements necessary for showing suggestion items used in text input autocomplete.", - "id": "GoogleAppsCardV1Suggestions", - "properties": { - "items": { - "description": "A list of suggestions items which will be used in are used in autocomplete.", - "items": { - "$ref": "GoogleAppsCardV1SuggestionItem" - }, - "type": "array" - } - }, - "type": "object" - }, - "GoogleAppsCardV1SwitchControl": { - "id": "GoogleAppsCardV1SwitchControl", - "properties": { - "controlType": { - "description": "The control type, either switch or checkbox.", - "enum": [ - "SWITCH", - "CHECKBOX", - "CHECK_BOX" - ], - "enumDescriptions": [ - "", - "Deprecated in favor of `CHECK_BOX`.", - "" - ], - "type": "string" - }, - "name": { - "description": "The name of the switch widget that's used in formInput.", - "type": "string" - }, - "onChangeAction": { - "$ref": "GoogleAppsCardV1Action", - "description": "The action when the switch state is changed." - }, - "selected": { - "description": "If the switch is selected.", - "type": "boolean" - }, - "value": { - "description": "The value is what is passed back in the callback.", - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1TextInput": { - "description": "A text input is a UI item where users can input text. A text input can also have an onChange action and suggestions.", - "id": "GoogleAppsCardV1TextInput", - "properties": { - "autoCompleteAction": { - "$ref": "GoogleAppsCardV1Action", - "description": "The refresh function that returns suggestions based on the user's input text. If the callback is not specified, autocomplete is done in client side based on the initial suggestion items." - }, - "hintText": { - "description": "The hint text.", - "type": "string" - }, - "initialSuggestions": { - "$ref": "GoogleAppsCardV1Suggestions", - "description": "The initial suggestions made before any user input." - }, - "label": { - "description": "At least one of label and hintText must be specified.", - "type": "string" - }, - "name": { - "description": "The name of the text input which is used in formInput.", - "type": "string" - }, - "onChangeAction": { - "$ref": "GoogleAppsCardV1Action", - "description": "The onChange action, for example, invoke a function." - }, - "type": { - "description": "The style of the text, for example, a single line or multiple lines.", - "enum": [ - "SINGLE_LINE", - "MULTIPLE_LINE" - ], - "enumDescriptions": [ - "The text is put into a single line.", - "The text is put into multiple lines." - ], - "type": "string" - }, - "value": { - "description": "The default value when there is no input from the user.", - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1TextParagraph": { - "description": "A paragraph of text that supports formatting. See [Text formatting](workspace/add-ons/concepts/widgets#text_formatting\") for details.", - "id": "GoogleAppsCardV1TextParagraph", - "properties": { - "text": { - "description": "The text that's shown in the widget.", - "type": "string" - } - }, - "type": "object" - }, - "GoogleAppsCardV1Widget": { - "description": "A widget is a UI element that presents texts, images, etc.", - "id": "GoogleAppsCardV1Widget", - "properties": { - "buttonList": { - "$ref": "GoogleAppsCardV1ButtonList", - "description": "A list of buttons. For example, the following JSON creates two buttons. The first is a filled text button and the second is an image button that opens a link: ``` \"buttonList\": { \"buttons\": [ \"button\": { \"text\": \"Edit\", \"Color\": { \"Red\": 255 \"Green\": 255 \"Blue\": 255 } \"disabled\": true }, \"button\": { \"icon\": { \"knownIcon\": \"INVITE\" \"altText\": \"check calendar\" }, \"onClick\": { \"openLink\": { \"url\": \"https://example.com/calendar\" } } }, ] } ```" - }, - "dateTimePicker": { - "$ref": "GoogleAppsCardV1DateTimePicker", - "description": "Displays a selection/input widget for date/time. For example, the following JSON creates a date/time picker for an appointment time: ``` \"date_time_picker\": { \"name\": \"appointment_time\", \"label\": \"Book your appointment at:\", \"type\": \"DateTimePickerType.DATE_AND_TIME\", \"valueMsEpoch\": \"796435200000\" } ```" - }, - "decoratedText": { - "$ref": "GoogleAppsCardV1DecoratedText", - "description": "Displays a decorated text item in this widget. For example, the following JSON creates a decorated text widget showing email address: ``` \"decoratedText\": { \"icon\": { \"knownIcon\": \"EMAIL\" }, \"topLabel\": \"Email Address\", \"content\": \"heba.salam@example.com\", \"bottomLabel\": \"This is a new Email address!\", \"switchWidget\": { \"name\": \"has_send_welcome_email_to_heba_salam\", \"selected\": false, \"controlType\": \"ControlType.CHECKBOX\" } } ```" - }, - "divider": { - "$ref": "GoogleAppsCardV1Divider", - "description": "Displays a divider. For example, the following JSON creates a divider: ``` \"divider\": { } ```" - }, - "grid": { - "$ref": "GoogleAppsCardV1Grid", - "description": "Displays a grid with a collection of items. For example, the following JSON creates a 2 column grid with a single item: ``` \"grid\": { \"title\": \"A fine collection of items\", \"numColumns\": 2, \"borderStyle\": { \"type\": \"STROKE\", \"cornerRadius\": 4.0 }, \"items\": [ \"image\": { \"imageUri\": \"https://www.example.com/image.png\", \"cropStyle\": { \"type\": \"SQUARE\" }, \"borderStyle\": { \"type\": \"STROKE\" } }, \"title\": \"An item\", \"textAlignment\": \"CENTER\" ], \"onClick\": { \"openLink\": { \"url\":\"https://www.example.com\" } } } ```" - }, - "horizontalAlignment": { - "description": "The horizontal alignment of this widget.", - "enum": [ - "HORIZONTAL_ALIGNMENT_UNSPECIFIED", - "START", - "CENTER", - "END" - ], - "enumDescriptions": [ - "Unspecified alignment.", - "Alignment to the start position.", - "Alignment to the center position.", - "Alignment to the end position." - ], - "type": "string" - }, - "image": { - "$ref": "GoogleAppsCardV1Image", - "description": "Displays an image in this widget. For example, the following JSON creates an image with alternative text: ``` \"image\": { \"imageUrl\": \"https://example.com/heba_salam.png\" \"altText\": \"Avatar for Heba Salam\" } ```" - }, - "selectionInput": { - "$ref": "GoogleAppsCardV1SelectionInput", - "description": "Displays a switch control in this widget. For example, the following JSON creates a dropdown selection for size: ``` \"switchControl\": { \"name\": \"size\", \"label\": \"Size\" \"type\": \"SelectionType.DROPDOWN\", \"items\": [ { \"text\": \"S\", \"value\": \"small\", \"selected\": false }, { \"text\": \"M\", \"value\": \"medium\", \"selected\": true }, { \"text\": \"L\", \"value\": \"large\", \"selected\": false }, { \"text\": \"XL\", \"value\": \"extra_large\", \"selected\": false } ] } ```" - }, - "textInput": { - "$ref": "GoogleAppsCardV1TextInput", - "description": "Displays a text input in this widget. For example, the following JSON creates a text input for mail address: ``` \"textInput\": { \"name\": \"mailing_address\", \"label\": \"Mailing Address\" } ``` As another example, the following JSON creates a text input for programming language with static suggestions: ``` \"textInput\": { \"name\": \"preferred_programing_language\", \"label\": \"Preferred Language\", \"initialSuggestions\": { \"items\": [ { \"text\": \"C++\" }, { \"text\": \"Java\" }, { \"text\": \"JavaScript\" }, { \"text\": \"Python\" } ] } } ```" - }, - "textParagraph": { - "$ref": "GoogleAppsCardV1TextParagraph", - "description": "Displays a text paragraph in this widget. For example, the following JSON creates a bolded text: ``` \"textParagraph\": { \"text\": \" *bold text*\" } ```" - } - }, - "type": "object" - }, "Image": { "description": "An image that is specified by a URL and can have an onclick action.", "id": "Image", @@ -2132,13 +1256,6 @@ }, "type": "array" }, - "cardsV2": { - "description": "Rich, formatted and interactive cards that can be used to display UI elements and editable widgets, such as: formatted text, buttons, clickable images, checkboxes, radio buttons. Cards are normally displayed below the plain-text body of the message. This v2 allows input widgets. The string key is a unique identifier among cards in the same message for identifying inputs.", - "items": { - "$ref": "CardWithId" - }, - "type": "array" - }, "createTime": { "description": "Output only. The time at which the message was created in Hangouts Chat server.", "format": "google-datetime",