UNPKG

googleapis

Version:
880 lines (879 loc) 170 kB
/// <reference types="node" /> import { OAuth2Client, JWT, Compute, UserRefreshClient, BaseExternalAccountClient, GaxiosPromise, GoogleConfigurable, MethodOptions, StreamMethodOptions, GlobalOptions, GoogleAuth, BodyResponseCallback, APIRequestContext } from 'googleapis-common'; import { Readable } from 'stream'; export declare namespace chat_v1 { export interface Options extends GlobalOptions { version: 'v1'; } interface StandardParameters { /** * Auth client or API Key for the request */ auth?: string | OAuth2Client | JWT | Compute | UserRefreshClient | BaseExternalAccountClient | GoogleAuth; /** * V1 error format. */ '$.xgafv'?: string; /** * OAuth access token. */ access_token?: string; /** * Data format for response. */ alt?: string; /** * JSONP */ callback?: string; /** * Selector specifying which fields to include in a partial response. */ fields?: string; /** * API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ key?: string; /** * OAuth 2.0 token for the current user. */ oauth_token?: string; /** * Returns response with indentations and line breaks. */ prettyPrint?: boolean; /** * Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ quotaUser?: string; /** * Legacy upload protocol for media (e.g. "media", "multipart"). */ uploadType?: string; /** * Upload protocol for media (e.g. "raw", "multipart"). */ upload_protocol?: string; } /** * Google Chat API * * Enables apps to fetch information and perform actions in Google Chat. Authentication is a prerequisite for using the Google Chat REST API. * * @example * ```js * const {google} = require('googleapis'); * const chat = google.chat('v1'); * ``` */ export class Chat { context: APIRequestContext; media: Resource$Media; spaces: Resource$Spaces; constructor(options: GlobalOptions, google?: GoogleConfigurable); } /** * List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze one day, snooze next week. You might use `action method = snooze()`, passing the snooze type and snooze time in the list of string parameters. */ export interface Schema$ActionParameter { /** * The name of the parameter for the action script. */ key?: string | null; /** * The value of the parameter. */ value?: string | null; } /** * Parameters that a Chat app can use to configure how its response is posted. */ export interface Schema$ActionResponse { /** * Input only. A response to an event related to a [dialog](https://developers.google.com/chat/how-tos/dialogs). Must be accompanied by `ResponseType.Dialog`. */ dialogAction?: Schema$DialogAction; /** * Input only. The type of Chat app response. */ type?: string | null; /** * Input only. URL for users to authenticate or configure. (Only for `REQUEST_CONFIG` response types.) */ url?: string | null; } /** * Represents the status for a request to either invoke or submit a [dialog](https://developers.google.com/chat/how-tos/dialogs). */ export interface Schema$ActionStatus { /** * The status code. */ statusCode?: string | null; /** * The message to send users about the status of their request. If unset, a generic message based on the `status_code` is sent. */ userFacingMessage?: string | null; } /** * Annotations associated with the plain-text body of the message. Example plain-text message body: ``` Hello @FooBot how are you!" ``` The corresponding annotations metadata: ``` "annotations":[{ "type":"USER_MENTION", "startIndex":6, "length":7, "userMention": { "user": { "name":"users/{user\}", "displayName":"FooBot", "avatarUrl":"https://goo.gl/aeDtrS", "type":"BOT" \}, "type":"MENTION" \} \}] ``` */ export interface Schema$Annotation { /** * Length of the substring in the plain-text message body this annotation corresponds to. */ length?: number | null; /** * The metadata for a slash command. */ slashCommand?: Schema$SlashCommandMetadata; /** * Start index (0-based, inclusive) in the plain-text message body this annotation corresponds to. */ startIndex?: number | null; /** * The type of this annotation. */ type?: string | null; /** * The metadata of user mention. */ userMention?: Schema$UserMentionMetadata; } /** * A GIF image that's specified by a URL. */ export interface Schema$AttachedGif { /** * Output only. The URL that hosts the GIF image. */ uri?: string | null; } /** * An attachment in Google Chat. */ export interface Schema$Attachment { /** * A reference to the attachment data. This field is used with the media API to download the attachment data. */ attachmentDataRef?: Schema$AttachmentDataRef; /** * Output only. The original file name for the content, not the full path. */ contentName?: string | null; /** * Output only. The content type (MIME type) of the file. */ contentType?: string | null; /** * Output only. The download URL which should be used to allow a human user to download the attachment. Chat apps shouldn't use this URL to download attachment content. */ downloadUri?: string | null; /** * Output only. A reference to the Google Drive attachment. This field is used with the Google Drive API. */ driveDataRef?: Schema$DriveDataRef; /** * Resource name of the attachment, in the form `spaces/x/messages/x/attachments/x`. */ name?: string | null; /** * Output only. The source of the attachment. */ source?: string | null; /** * Output only. The thumbnail URL which should be used to preview the attachment to a human user. Chat apps shouldn't use this URL to download attachment content. */ thumbnailUri?: string | null; } export interface Schema$AttachmentDataRef { /** * Opaque token containing a reference to an uploaded attachment. Treated by clients as an opaque string and used to create or update Chat messages with attachments. */ attachmentUploadToken?: string | null; /** * The resource name of the attachment data. This field is used with the media API to download the attachment data. */ resourceName?: string | null; } /** * A button. Can be a text button or an image button. */ export interface Schema$Button { /** * A button with image and `onclick` action. */ imageButton?: Schema$ImageButton; /** * A button with text and `onclick` action. */ textButton?: Schema$TextButton; } /** * A card is a UI element that can contain UI widgets such as text and images. */ export interface Schema$Card { /** * The actions of this card. */ cardActions?: Schema$CardAction[]; /** * The header of the card. A header usually contains a title and an image. */ header?: Schema$CardHeader; /** * Name of the card. */ name?: string | null; /** * Sections are separated by a line divider. */ sections?: Schema$Section[]; } /** * A card action is the action associated with the card. For an invoice card, a typical action would be: delete invoice, email invoice or open the invoice in browser. Not supported by Google Chat apps. */ export interface Schema$CardAction { /** * The label used to be displayed in the action menu item. */ actionLabel?: string | null; /** * The onclick action for this action item. */ onClick?: Schema$OnClick; } export interface Schema$CardHeader { /** * The image's type (for example, square border or circular border). */ imageStyle?: string | null; /** * The URL of the image in the card header. */ imageUrl?: string | null; /** * The subtitle of the card header. */ subtitle?: string | null; /** * The title must be specified. The header has a fixed height: if both a title and subtitle is specified, each takes up one line. If only the title is specified, it takes up both lines. */ title?: string | null; } /** * Widgets for Chat apps to specify. */ export interface Schema$CardWithId { /** * Cards support a defined layout, interactive UI elements like buttons, and rich media like images. Use this card to present detailed information, gather information from users, and guide users to take a next step. */ card?: Schema$GoogleAppsCardV1Card; /** * Required for `cardsV2` messages. Chat app-specified identifier for this widget. Scoped within a message. */ cardId?: string | null; } /** * JSON payload of error messages. If the Cloud Logging API is enabled, these error messages are logged to [Google Cloud Logging](https://cloud.google.com/logging/docs). */ export interface Schema$ChatAppLogEntry { /** * The deployment that caused the error. For Chat apps built in Apps Script, this is the deployment ID defined by Apps Script. */ deployment?: string | null; /** * The unencrypted `callback_method` name that was running when the error was encountered. */ deploymentFunction?: string | null; /** * The error code and message. */ error?: Schema$Status; } /** * Chat apps only. For a `SelectionInput` widget that uses a multi-select menu, a data source from Google Chat. For example, a list of Google Chat spaces of which the user is a member. [Developer Preview](https://developers.google.com/workspace/preview). */ export interface Schema$ChatClientDataSourceMarkup { /** * A data source representing a Google Chat space. Format: spaces/{space\} [Developer Preview](https://developers.google.com/workspace/preview). */ spaceDataSource?: Schema$SpaceDataSource; } /** * Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to and 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 have information about the absolute color space that should be used to interpret the RGB value—for example, sRGB, Adobe RGB, DCI-P3, and BT.2020. 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(''); \}; // ... */ export interface Schema$Color { /** * 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). */ alpha?: number | null; /** * The amount of blue in the color as a value in the interval [0, 1]. */ blue?: number | null; /** * The amount of green in the color as a value in the interval [0, 1]. */ green?: number | null; /** * The amount of red in the color as a value in the interval [0, 1]. */ red?: number | null; } /** * Represents information about the user's client, such as locale, host app, and platform. For Chat apps, `CommonEventObject` includes data submitted by users interacting with cards, like data entered in [dialogs](https://developers.google.com/chat/how-tos/dialogs). */ export interface Schema$CommonEventObject { /** * A map containing the current values of the widgets in a card. The map keys are the string IDs assigned to each widget, and the values represent inputs to the widget. Depending on the input data type, a different object represents each input: For single-value widgets, `StringInput`. For multi-value widgets, an array of `StringInput` objects. For a date-time picker, a `DateTimeInput`. For a date-only picker, a `DateInput`. For a time-only picker, a `TimeInput`. Corresponds with the data entered by a user on a card in a [dialog](https://developers.google.com/chat/how-tos/dialogs). */ formInputs?: { [key: string]: Schema$Inputs; } | null; /** * The hostApp enum which indicates the app the add-on is invoked from. Always `CHAT` for Chat apps. */ hostApp?: string | null; /** * Name of the invoked function associated with the widget. Only set for Chat apps. */ invokedFunction?: string | null; /** * Custom [parameters](/chat/api/reference/rest/v1/cards#ActionParameter) passed to the invoked function. Both keys and values must be strings. */ parameters?: { [key: string]: string; } | null; /** * The platform enum which indicates the platform where the event originates (`WEB`, `IOS`, or `ANDROID`). Not supported by Chat apps. */ platform?: string | null; /** * The timezone ID and offset from Coordinated Universal Time (UTC). Only supported for the event types [`CARD_CLICKED`](https://developers.google.com/chat/api/reference/rest/v1/EventType#ENUM_VALUES.CARD_CLICKED) and [`SUBMIT_DIALOG`](https://developers.google.com/chat/api/reference/rest/v1/DialogEventType#ENUM_VALUES.SUBMIT_DIALOG). */ timeZone?: Schema$TimeZone; /** * The full `locale.displayName` in the format of [ISO 639 language code]-[ISO 3166 country/region code] such as "en-US". */ userLocale?: string | null; } /** * Represents a custom emoji. */ export interface Schema$CustomEmoji { /** * Unique key for the custom emoji resource. */ uid?: string | null; } /** * Date input values. */ export interface Schema$DateInput { /** * Time since epoch time, in milliseconds. */ msSinceEpoch?: string | null; } /** * Date and time input values. */ export interface Schema$DateTimeInput { /** * Whether the `datetime` input includes a calendar date. */ hasDate?: boolean | null; /** * Whether the `datetime` input includes a timestamp. */ hasTime?: boolean | null; /** * Time since epoch time, in milliseconds. */ msSinceEpoch?: string | null; } /** * Information about a deleted message. A message is deleted when `delete_time` is set. */ export interface Schema$DeletionMetadata { /** * Indicates who deleted the message. */ deletionType?: string | null; } /** * Google Chat events. To learn how to use events, see [Receive and respond to Google Chat events](https://developers.google.com/chat/api/guides/message-formats). */ export interface Schema$DeprecatedEvent { /** * The form action data associated with an interactive card that was clicked. Only populated for CARD_CLICKED events. See the [Interactive Cards guide](/chat/how-tos/cards-onclick) for more information. */ action?: Schema$FormAction; /** * Represents information about the user's client, such as locale, host app, and platform. For Chat apps, `CommonEventObject` includes information submitted by users interacting with [dialogs](https://developers.google.com/chat/how-tos/dialogs), like data entered on a card. */ common?: Schema$CommonEventObject; /** * The URL the Chat app should redirect the user to after they have completed an authorization or configuration flow outside of Google Chat. For more information, see [Connect a Chat app with other services & tools](https://developers.google.com/chat/how-tos/connect-web-services-tools). */ configCompleteRedirectUrl?: string | null; /** * The type of [dialog](https://developers.google.com/chat/how-tos/dialogs) event received. */ dialogEventType?: string | null; /** * The timestamp indicating when the event occurred. */ eventTime?: string | null; /** * True when the event is related to [dialogs](https://developers.google.com/chat/how-tos/dialogs). */ isDialogEvent?: boolean | null; /** * The message that triggered the event, if applicable. */ message?: Schema$Message; /** * The space in which the event occurred. */ space?: Schema$Space; /** * The Chat app-defined key for the thread related to the event. See [`spaces.messages.thread.threadKey`](/chat/api/reference/rest/v1/spaces.messages#Thread.FIELDS.thread_key) for more information. */ threadKey?: string | null; /** * A secret value that legacy Chat apps can use to verify if a request is from Google. Google randomly generates the token, and its value remains static. You can obtain, revoke, or regenerate the token from the [Chat API configuration page](https://console.cloud.google.com/apis/api/chat.googleapis.com/hangouts-chat) in the Google Cloud Console. Modern Chat apps don't use this field. It is absent from API responses and the [Chat API configuration page](https://console.cloud.google.com/apis/api/chat.googleapis.com/hangouts-chat). */ token?: string | null; /** * The type of the event. */ type?: string | null; /** * The user that triggered the event. */ user?: Schema$User; } /** * Wrapper around the card body of the dialog. */ export interface Schema$Dialog { /** * Input only. Body of the dialog, which is rendered in a modal. Google Chat apps don't support the following card entities: `DateTimePicker`, `OnChangeAction`. */ body?: Schema$GoogleAppsCardV1Card; } /** * Contains a [dialog](https://developers.google.com/chat/how-tos/dialogs) and request status code. */ export interface Schema$DialogAction { /** * Input only. Status for a request to either invoke or submit a [dialog](https://developers.google.com/chat/how-tos/dialogs). Displays a status and message to users, if necessary. For example, in case of an error or success. */ actionStatus?: Schema$ActionStatus; /** * Input only. [Dialog](https://developers.google.com/chat/how-tos/dialogs) for the request. */ dialog?: Schema$Dialog; } /** * A reference to the data of a drive attachment. */ export interface Schema$DriveDataRef { /** * The ID for the drive file. Use with the Drive API. */ driveFileId?: string | null; } /** * An emoji that is used as a reaction to a message. */ export interface Schema$Emoji { /** * Output only. A custom emoji. */ customEmoji?: Schema$CustomEmoji; /** * A basic emoji represented by a unicode string. */ unicode?: string | null; } /** * The number of people who reacted to a message with a specific emoji. */ export interface Schema$EmojiReactionSummary { /** * Emoji associated with the reactions. */ emoji?: Schema$Emoji; /** * The total number of reactions using the associated emoji. */ reactionCount?: number | null; } /** * A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); \} */ export interface Schema$Empty { } /** * A form action describes the behavior when the form is submitted. For example, you can invoke Apps Script to handle the form. */ export interface Schema$FormAction { /** * The method name is used to identify which part of the form triggered the form submission. This information is echoed back to the Chat app as part of the card click event. You can use the same method name for several elements that trigger a common behavior. */ actionMethodName?: string | null; /** * List of action parameters. */ parameters?: Schema$ActionParameter[]; } /** * An action that describes the behavior when the form is submitted. For example, you can invoke an Apps Script script to handle the form. If the action is triggered, the form values are sent to the server. */ export interface Schema$GoogleAppsCardV1Action { /** * A custom function to invoke when the containing element is clicked or othrwise activated. For example usage, see [Create interactive cards](https://developers.google.com/chat/how-tos/cards-onclick). */ function?: string | null; /** * Optional. Required when opening a [dialog](https://developers.google.com/chat/how-tos/dialogs). What to do in response to an interaction with a user, such as a user clicking a button in a card message. If unspecified, the app responds by executing an `action`—like opening a link or running a function—as normal. By specifying an `interaction`, the app can respond in special interactive ways. For example, by setting `interaction` to `OPEN_DIALOG`, the app can open a [dialog](https://developers.google.com/chat/how-tos/dialogs). When specified, a loading indicator isn't shown. Supported by Chat apps, but not Google Workspace Add-ons. If specified for an add-on, the entire card is stripped and nothing is shown in the client. */ interaction?: string | null; /** * Specifies the loading indicator that the action displays while making the call to the action. */ loadIndicator?: string | null; /** * List of action parameters. */ parameters?: Schema$GoogleAppsCardV1ActionParameter[]; /** * Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. To let the user make changes while the action is being processed, set [`LoadIndicator`](https://developers.google.com/workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) to `NONE`. For [card messages](https://developers.google.com/chat/api/guides/message-formats/cards) in Chat apps, you must also set the action's [`ResponseType`](https://developers.google.com/chat/api/reference/rest/v1/spaces.messages#responsetype) to `UPDATE_MESSAGE` and use the same [`card_id`](https://developers.google.com/chat/api/reference/rest/v1/spaces.messages#CardWithId) from the card that contained the action. If `false`, the form values are cleared when the action is triggered. To prevent the user from making changes while the action is being processed, set [`LoadIndicator`](https://developers.google.com/workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) to `SPINNER`. */ persistValues?: boolean | null; } /** * List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze one day, or snooze next week. You might use `action method = snooze()`, passing the snooze type and snooze time in the list of string parameters. To learn more, see [`CommonEventObject`](https://developers.google.com/chat/api/reference/rest/v1/Event#commoneventobject). */ export interface Schema$GoogleAppsCardV1ActionParameter { /** * The name of the parameter for the action script. */ key?: string | null; /** * The value of the parameter. */ value?: string | null; } /** * The style options for the border of a card or widget, including the border type and color. */ export interface Schema$GoogleAppsCardV1BorderStyle { /** * The corner radius for the border. */ cornerRadius?: number | null; /** * The colors to use when the type is `BORDER_TYPE_STROKE`. */ strokeColor?: Schema$Color; /** * The border type. */ type?: string | null; } /** * A text, icon, or text and icon button that users can click. For an example in Google Chat apps, see [Button list](https://developers.google.com/chat/ui/widgets/button-list). To make an image a clickable button, specify an `Image` (not an `ImageComponent`) and set an `onClick` action. */ export interface Schema$GoogleAppsCardV1Button { /** * The alternative text that's used for accessibility. Set descriptive text that lets users know what the button does. For example, if a button opens a hyperlink, you might write: "Opens a new browser tab and navigates to the Google Chat developer documentation at https://developers.google.com/chat". */ altText?: string | null; /** * If set, the button is filled with a solid background color and the font color changes to maintain contrast with the background color. For example, setting a blue background likely results in white text. If unset, the image background is white and the font color is blue. For red, green, and blue, the value of each field is a `float` number that you can express in either of two ways: as a number between 0 and 255 divided by 255 (153/255), or as a value between 0 and 1 (0.6). 0 represents the absence of a color and 1 or 255/255 represent the full presence of that color on the RGB scale. Optionally set `alpha`, which sets a level of transparency using this equation: ``` pixel color = alpha * (this color) + (1.0 - alpha) * (background color) ``` For `alpha`, a value of `1` corresponds with a solid color, and a value of `0` corresponds with a completely transparent color. For example, the following color represents a half transparent red: ``` "color": { "red": 1, "green": 0, "blue": 0, "alpha": 0.5 \} ``` */ color?: Schema$Color; /** * If `true`, the button is displayed in an inactive state and doesn't respond to user actions. */ disabled?: boolean | null; /** * The icon image. If both `icon` and `text` are set, then the icon appears before the text. */ icon?: Schema$GoogleAppsCardV1Icon; /** * Required. The action to perform when a user clicks the button, such as opening a hyperlink or running a custom function. */ onClick?: Schema$GoogleAppsCardV1OnClick; /** * The text displayed inside the button. */ text?: string | null; } /** * A list of buttons layed out horizontally. For an example in Google Chat apps, see [Button list](https://developers.google.com/chat/ui/widgets/button-list). */ export interface Schema$GoogleAppsCardV1ButtonList { /** * An array of buttons. */ buttons?: Schema$GoogleAppsCardV1Button[]; } /** * Cards support a defined layout, interactive UI elements like buttons, and rich media like images. Use cards to present detailed information, gather information from users, and guide users to take a next step. In Google Chat, cards appear in several places: - As stand-alone messages. - Accompanying a text message, just beneath the text message. - As a [dialog](https://developers.google.com/chat/how-tos/dialogs). The following example JSON creates a "contact card" that features: - A header with the contact's name, job title, and avatar picture. - A section with the contact information, including formatted text. - Buttons that users can click to share the contact, or see more or less information. For more examples, see [Design dynamic, interactive, and consistent UIs with cards](https://developers.google.com/chat/ui). ![Example contact card](https://developers.google.com/chat/images/card_api_reference.png) ``` { "cardsV2": [ { "cardId": "unique-card-id", "card": { "header": { "title": "Sasha", "subtitle": "Software Engineer", "imageUrl": "https://developers.google.com/chat/images/quickstart-app-avatar.png", "imageType": "CIRCLE", "imageAltText": "Avatar for Sasha", \}, "sections": [ { "header": "Contact Info", "collapsible": true, "uncollapsibleWidgetsCount": 1, "widgets": [ { "decoratedText": { "startIcon": { "knownIcon": "EMAIL", \}, "text": "sasha@example.com", \} \}, { "decoratedText": { "startIcon": { "knownIcon": "PERSON", \}, "text": "Online", \}, \}, { "decoratedText": { "startIcon": { "knownIcon": "PHONE", \}, "text": "+1 (555) 555-1234", \} \}, { "buttonList": { "buttons": [ { "text": "Share", "onClick": { "openLink": { "url": "https://example.com/share", \} \} \}, { "text": "Edit", "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT", \} ], \} \} \}, ], \} \}, ], \}, ], \}, \} ], \} ``` */ export interface Schema$GoogleAppsCardV1Card { /** * The card's actions. Actions are added to the card's toolbar menu. Because Chat app cards have no toolbar, `cardActions[]` isn't supported by Chat apps. For example, the following JSON constructs a card action menu with `Settings` and `Send Feedback` options: ``` "card_actions": [ { "actionLabel": "Settings", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" \} ], "loadIndicator": "LoadIndicator.SPINNER" \} \} \}, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" \} \} \} ] ``` */ cardActions?: Schema$GoogleAppsCardV1CardAction[]; /** * In Google Workspace add-ons, sets the display properties of the `peekCardHeader`. Not supported by Chat apps. */ displayStyle?: string | null; /** * The fixed footer shown at the bottom of this card. Setting `fixedFooter` without specifying a `primaryButton` or a `secondaryButton` causes an error. Supported by Google Workspace Add-ons and Chat apps. For Chat apps, you can use fixed footers in [dialogs](https://developers.google.com/chat/how-tos/dialogs), but not [card messages](https://developers.google.com/chat/api/guides/message-formats/cards). */ fixedFooter?: Schema$GoogleAppsCardV1CardFixedFooter; /** * The header of the card. A header usually contains a leading image and a title. Headers always appear at the top of a card. */ header?: Schema$GoogleAppsCardV1CardHeader; /** * Name of the card. Used as a card identifier in card navigation. Because Chat apps don't support card navigation, they ignore this field. */ name?: string | null; /** * 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. Not supported by Chat apps. */ peekCardHeader?: Schema$GoogleAppsCardV1CardHeader; /** * The divider style between sections. */ sectionDividerStyle?: string | null; /** * Contains a collection of widgets. Each section has its own, optional header. Sections are visually separated by a line divider. For an example in Google Chat apps, see [Card section](https://developers.google.com/chat/ui/widgets/card-section). */ sections?: Schema$GoogleAppsCardV1Section[]; } /** * 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. Not supported by Chat apps. */ export interface Schema$GoogleAppsCardV1CardAction { /** * The label that displays as the action menu item. */ actionLabel?: string | null; /** * The `onClick` action for this action item. */ onClick?: Schema$GoogleAppsCardV1OnClick; } /** * A persistent (sticky) footer that that appears at the bottom of the card. For an example in Google Chat apps, see [Card footer](https://developers.google.com/chat/ui/widgets/card-fixed-footer). Setting `fixedFooter` without specifying a `primaryButton` or a `secondaryButton` causes an error. Supported by Google Workspace Add-ons and Chat apps. For Chat apps, you can use fixed footers in [dialogs](https://developers.google.com/chat/how-tos/dialogs), but not [card messages](https://developers.google.com/chat/api/guides/message-formats/cards). */ export interface Schema$GoogleAppsCardV1CardFixedFooter { /** * The primary button of the fixed footer. The button must be a text button with text and color set. */ primaryButton?: Schema$GoogleAppsCardV1Button; /** * The secondary button of the fixed footer. The button must be a text button with text and color set. If `secondaryButton` is set, you must also set `primaryButton`. */ secondaryButton?: Schema$GoogleAppsCardV1Button; } /** * Represents a card header. For an example in Google Chat apps, see [Card header](https://developers.google.com/chat/ui/widgets/card-header). */ export interface Schema$GoogleAppsCardV1CardHeader { /** * The alternative text of this image that's used for accessibility. */ imageAltText?: string | null; /** * The shape used to crop the image. */ imageType?: string | null; /** * The HTTPS URL of the image in the card header. */ imageUrl?: string | null; /** * The subtitle of the card header. If specified, appears on its own line below the `title`. */ subtitle?: string | null; /** * Required. The title of the card header. 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. */ title?: string | null; } /** * A column. */ export interface Schema$GoogleAppsCardV1Column { /** * Specifies whether widgets align to the left, right, or center of a column. */ horizontalAlignment?: string | null; /** * Specifies how a column fills the width of the card. */ horizontalSizeStyle?: string | null; /** * Specifies whether widgets align to the top, bottom, or center of a column. */ verticalAlignment?: string | null; /** * An array of widgets included in a column. Widgets appear in the order that they are specified. */ widgets?: Schema$GoogleAppsCardV1Widgets[]; } /** * The `Columns` widget displays up to 2 columns in a card message or dialog. You can add widgets to each column; the widgets appear in the order that they are specified. For an example in Google Chat apps, see [Columns](https://developers.google.com/chat/ui/widgets/columns). The height of each column is determined by the taller column. For example, if the first column is taller than the second column, both columns have the height of the first column. Because each column can contain a different number of widgets, you can't define rows or align widgets between the columns. Columns are displayed side-by-side. You can customize the width of each column using the `HorizontalSizeStyle` field. If the user's screen width is too narrow, the second column wraps below the first: * On web, the second column wraps if the screen width is less than or equal to 480 pixels. * On iOS devices, the second column wraps if the screen width is less than or equal to 300 pt. * On Android devices, the second column wraps if the screen width is less than or equal to 320 dp. To include more than 2 columns, or to use rows, use the `Grid` widget. Supported by Chat apps, but not Google Workspace Add-ons. */ export interface Schema$GoogleAppsCardV1Columns { /** * An array of columns. You can include up to 2 columns in a card or dialog. */ columnItems?: Schema$GoogleAppsCardV1Column[]; } /** * Lets users input a date, a time, or both a date and a time. For an example in Google Chat apps, see [Date time picker](https://developers.google.com/chat/ui/widgets/date-time-picker). Users can input text or use the picker to select dates and times. If users input an invalid date or time, the picker shows an error that prompts users to input the information correctly. */ export interface Schema$GoogleAppsCardV1DateTimePicker { /** * The text that prompts users to input a date, a time, or a date and time. For example, if users are scheduling an appointment, use a label such as `Appointment date` or `Appointment date and time`. */ label?: string | null; /** * The name by which the `DateTimePicker` is identified in a form input event. For details about working with form inputs, see [Receive form data](https://developers.google.com/chat/ui/read-form-data). */ name?: string | null; /** * Triggered when the user clicks **Save** or **Clear** from the `DateTimePicker` interface. */ onChangeAction?: Schema$GoogleAppsCardV1Action; /** * 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 unset, the value defaults to the user's time zone setting. */ timezoneOffsetDate?: number | null; /** * Whether the widget supports inputting a date, a time, or the date and time. */ type?: string | null; /** * The default value displayed in the widget, in milliseconds since [Unix epoch time](https://en.wikipedia.org/wiki/Unix_time). Specify the value based on the type of picker (`DateTimePickerType`): * `DATE_AND_TIME`: a calendar date and time in UTC. For example, to represent January 1, 2023 at 12:00 PM UTC, use `1672574400000`. * `DATE_ONLY`: a calendar date at 00:00:00 UTC. For example, to represent January 1, 2023, use `1672531200000`. * `TIME_ONLY`: a time in UTC. For example, to represent 12:00 PM, use `43200000` (or `12 * 60 * 60 * 1000`). */ valueMsEpoch?: string | null; } /** * 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. For an example in Google Chat apps, see [Decorated text](https://developers.google.com/chat/ui/widgets/decorated-text). */ export interface Schema$GoogleAppsCardV1DecoratedText { /** * The text that appears below `text`. Always wraps. */ bottomLabel?: string | null; /** * A button that a user can click to trigger an action. */ button?: Schema$GoogleAppsCardV1Button; /** * An icon displayed after the text. Supports [built-in](https://developers.google.com/chat/api/guides/message-formats/cards#builtinicons) and [custom](https://developers.google.com/chat/api/guides/message-formats/cards#customicons) icons. */ endIcon?: Schema$GoogleAppsCardV1Icon; /** * Deprecated in favor of `startIcon`. */ icon?: Schema$GoogleAppsCardV1Icon; /** * This action is triggered when users click `topLabel` or `bottomLabel`. */ onClick?: Schema$GoogleAppsCardV1OnClick; /** * The icon displayed in front of the text. */ startIcon?: Schema$GoogleAppsCardV1Icon; /** * A switch widget that a user can click to change its state and trigger an action. */ switchControl?: Schema$GoogleAppsCardV1SwitchControl; /** * Required. The primary text. Supports simple formatting. For more information about formatting text, see [Formatting text in Google Chat apps](https://developers.google.com/chat/api/guides/message-formats/cards#card-formatting) and [Formatting text in Google Workspace Add-ons](https://developers.google.com/apps-script/add-ons/concepts/widgets#text_formatting). */ text?: string | null; /** * The text that appears above `text`. Always truncates. */ topLabel?: string | null; /** * The wrap text setting. If `true`, the text wraps and displays on multiple lines. Otherwise, the text is truncated. Only applies to `text`, not `topLabel` and `bottomLabel`. */ wrapText?: boolean | null; } /** * Displays a divider between widgets as a horizontal line. For an example in Google Chat apps, see [Divider](https://developers.google.com/chat/ui/widgets/divider). For example, the following JSON creates a divider: ``` "divider": {\} ``` */ export interface Schema$GoogleAppsCardV1Divider { } /** * Displays a grid with a collection of items. Items can only include text or images. For responsive columns, or to include more than text or images, use `Columns`. For an example in Google Chat apps, see [Grid](https://developers.google.com/chat/ui/widgets/grid). A grid supports any number of columns and items. The number of rows is determined by items divided by columns. A grid with 10 items and 2 columns has 5 rows. A grid with 11 items and 2 columns has 6 rows. For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "columnCount": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4 \}, "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" \} \} \} ``` */ export interface Schema$GoogleAppsCardV1Grid { /** * The border style to apply to each grid item. */ borderStyle?: Schema$GoogleAppsCardV1BorderStyle; /** * 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). */ columnCount?: number | null; /** * The items to display in the grid. */ items?: Schema$GoogleAppsCardV1GridItem[]; /** * 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. */ onClick?: Schema$GoogleAppsCardV1OnClick; /** * The text that displays in the grid header. */ title?: string | null; } /** * Represents an item in a grid layout. Items can contain text, an image, or both text and an image. */ export interface Schema$GoogleAppsCardV1GridItem { /** * A user-specified identifier for this grid item. This identifier is returned in the parent grid's `onClick` callback parameters. */ id?: string | null; /** * The image that displays in the grid item. */ image?: Schema$GoogleAppsCardV1ImageComponent; /** * The layout to use for the grid item. */ layout?: string | null; /** * The grid item's subtitle. */ subtitle?: string | null; /** * The grid item's title. */ title?: string | null; } /** * An icon displayed in a widget on a card. For an example in Google Chat apps, see [Icon](https://developers.google.com/chat/ui/widgets/icon). Supports [built-in](https://developers.google.com/chat/api/guides/message-formats/cards#builtinicons) and [custom](https://developers.google.com/chat/api/guides/message-formats/cards#customicons) icons. */ export interface Schema$GoogleAppsCardV1Icon { /** * Optional. A description of the icon used for accessibility. If unspecified, the default value `Button` is provided. As a best practice, you should set a helpful description for what the icon displays, and if applicable, what it does. For example, `A user's account portrait`, or `Opens a new browser tab and navigates to the Google Chat developer documentation at https://developers.google.com/chat`. If the icon is set in a `Button`, the `altText` appears as helper text when the user hovers over the button. However, if the button also sets `text`, the icon's `altText` is ignored. */