AI-generated Key Takeaways
-
Event objects are JSON structures that provide context and user interaction data to Google Workspace add-ons.
-
They consist of a
commonEventObjectfor general information and host-specific objects likecalendarEventObjectordriveEventObject. -
Developers should prioritize the new event structure and avoid deprecated Gmail add-on fields.
-
Accessing event object data depends on widget type, host app, and required permissions defined in the manifest.
-
Understanding the structure of
formInputs, calendar event details, attendee information, and Drive item data is crucial for effective add-on functionality.
This page outlines the structure of Google Workspace add-ons event objects.
Event objects are JSON structures that are automatically constructed and passed as parameters to trigger or callback functions when a user interacts with an add-on. Event objects carry client-side information about the host app and the current context to the add-on's server-side callback function.
Google Workspace add-ons use event objects in the following places:
Homepage triggers. Every
homepageTriggerfunction you define is automatically passed an event object when the homepage trigger function fires. You can use this object in your homepage trigger function to identify the active host app, the client's platform, the user locale, and other information.The event objects created when homepage triggers fire don't contain all the fields included in the other two cases; fields pertaining to widgets and contextual information are omitted.
Contextual triggers. Each host application provides a different set of contextual triggers that fire when the user enters a specific context. For example:
- Gmail provides a contextual trigger for when a user opens a message and another when a user composes a message.
- Google Calendar provides a contextual trigger for when a user opens an event.
- Google Drive provides a contextual trigger for when a user selects Drive files.
When a contextual trigger fires, the host application calls the corresponding
runFunctionlisted in the add-on manifest, passing it an event object as a parameter. The event objects created when contextual triggers fire contain all the fields included in homepage trigger event objects, plus fields containing contextual information.Widget actions. Event objects are also used to provide widget interactivity, using the same action model that Gmail add-ons use. Google Workspace add-ons use all the same widget handler functions,
Actionobjects, and action responses. However, in Google Workspace add-ons the action event objects include even more information a callback function can act on.The event objects created as the result of widget actions contain all the fields included in contextual trigger event objects, plus fields containing widget information.
Preview link triggers. In Google Docs, Sheets, and Slides, you can configure link previews for third-party services based on specific URL patterns. When users interact with a link that meets the pattern, the
linkPreviewTriggersfires and an event object that contains the link is passed to the trigger's callback function. Your add-on can use this event object to construct a smart chip and card that surfaces information about the link within the host application. You can also build widget actions to let users interact with the preview card and its contents.Google Chat app triggers. In Google Chat, your add-on appears to users as a Chat app, and users can interact with it by adding it to spaces, sending messages, using slash commands, and more. To build interactive features, you set up and use various Chat app triggers. Each trigger sends a different event object payload that helps you process or respond to each type of interaction.
Event object structure
The following table describes the top-level structure of Google Workspace add-ons event objects. The event object structure includes a commonEventObject top-level field for host-independent information. Each event object can also have one of the following host-specific top-level fields, determined by the active host app: gmailEventObject, calendarEventObject, or driveEventObject.
For backward compatibility, Google Workspace add-ons event objects also include all the original fields used in Gmail add-on action event objects. These fields are listed in the table below under "Original Gmail add-on fields"; the information in these fields is reproduced in new object structure.
| Event object | |
|---|---|
eventObject.commonEventObject | Common fields object An object containing information common to all event objects, regardless of the host application. |
eventObject.calendar | Calendar event object Only present if the calling host is Google Calendar. An object containing calendar and event information. |
eventObject.chat | Chat event object Only present if the calling host is Google Chat. An object containing Chat information. |
eventObject.drive | Drive event object Only present if the calling host is Google Drive. An object containing Drive information. |
eventObject.gmail | Gmail event object Only present if the calling host is Gmail. An object containing Gmail information. |
eventObject.docs | Docs event object Only present if the calling host is Google Docs. An object containing Docs information. |
eventObject.sheets | Sheets event object Only present if the calling host is Google Sheets. An object containing Sheets information. |
eventObject.slides | Slides event object Only present if the calling host is Google Slides. An object containing Slides information. |
| Original Gmail add-on fields | |
eventObject.messageMetadata.accessToken | stringDeprecated. An access token. You can use this to turn on access to user data using temporary Gmail add-on scopes. For Google Workspace add-ons, find this information in the |
eventObject.messageMetadata.messageId | stringDeprecated. The message ID of the thread open in the Gmail UI. For Google Workspace add-ons, find this information in the |
eventObject.clientPlatform | stringDeprecated. Indicates where the event originates (web, iOS, or Android). For Google Workspace add-ons, find this information in the |
eventObject.formInput | objectDeprecated. A map of the current values of all form widgets in the card, restricted to one value per widget. The keys are the string IDs associated with the widgets, and the values are strings. The event object provides formInput as a convenience for when you need to read data from multiple widgets with expected singular values, such as text inputs and switches. For multi-valued widgets such as checkboxes, you can read each value from formInputs instead. For Google Workspace add-ons, find this information in the |
eventObject.formInputs | objectDeprecated. A map of current values of widgets in the card, presented as lists of strings. The keys are the string IDs associated with the widget. For single-valued widgets, the value is presented in a single-element array. For multi-valued widgets such as checkbox groups, all the values are presented in a list. For Google Workspace add-ons, find this information in the |
eventObject.parameters | objectDeprecated. A map of any additional parameters you supply to the Action using Action.setParameters(). The map keys and values are strings. For Google Workspace add-ons, find this information in the |
eventObject.userCountry | stringDeprecated and disabled by default. The two-letter code indicating the user's country or region. It can also be a numeric UN M49 country code. For Google Workspace add-ons, find this information in the |
eventObject.userLocale | stringDeprecated and disabled by default. The two-letter ISO 639 code indicating the user's language. See Accessing user locale and timezone for more details. For Google Workspace add-ons, find this information in the |
eventObject.userTimezone.id | stringDeprecated and disabled by default. The timezone identifier of the user's timezone. Examples include: America/New_York, Europe/Vienna, and Asia/Seoul. See Accessing user locale and timezone for more details. For Google Workspace add-ons, find this information in the |
eventObject.userTimezone.offset | stringDeprecated and disabled by default. The time offset from Coordinated Universal Time (UTC) of the user's timezone, measured in milliseconds. See Accessing user locale and timezone for more details. For Google Workspace add-ons, find this information in the |
Common event object
The common event object is the portion of the overall event object that carries general, host-independent information to the add-on from the user's client. This information includes details such as the user's locale, host app, and platform.
In addition to homepage and contextual triggers, add-ons construct and pass event objects to action callback functions when the user interacts with widgets. Your add-on's callback function can query the common event object to determine the contents of open widgets in the user's client. For example, your add-on can locate the text a user has entered into a TextInput widget in the eventObject.commentEventObject.formInputs object.
| Common event object fields | |
|---|---|
commonEventObject.platform | stringIndicates where the event originates (`WEB`, `IOS`, or `ANDROID`). |
commonEventObject.formInputs | objectA map containing the current values of the widgets in the displayed card. The map keys are the string IDs assigned with each widget. The structure of the map value object is dependent on the widget type: For example, instead of To learn more about runtimes in Apps Script, see the V8 Runtime Overview.
|
commonEventObject.hostApp | stringIndicates the host app the add-on is active in when the event object is generated. Possible values include the following:
|
commonEventObject.parameters | objectAny additional parameters you supply to an action using actionParameters or Action.setParameters(). Developer Preview: For add-ons that extend Google Chat, to suggest items based on what the users type in multiselect menus, use the value of the |
commonEventObject.userLocale | stringDisabled by default. The user's language and country/region identifier in the format of ISO 639 language code-ISO 3166 country/region code. For example, en-US. To turn on this field, you must set |
commonEventObject.timeZone | stringDisabled by default. The timezone ID and offset. To turn on this field, you must set addOns.common.useLocaleFromApp to true in your add-on's manifest. Your add-on's scope list must also include https://www.googleapis.com/auth/script.locale. See Accessing user locale and timezone for more details. |
commonEventObject.timeZone.id | stringThe timezone identifier of the user's timezone. Examples include: America/New_York, Europe/Vienna, and Asia/Seoul. To turn on this field, you must set addOns.common.useLocaleFromApp to true in your add-on's manifest. Your add-on's scope list must also include https://www.googleapis.com/auth/script.locale. See Accessing user locale and timezone for more details. |
commonEventObject.timeZone.offset | stringThe time offset from Coordinated Universal Time (UTC) of the user's timezone, measured in milliseconds. See Accessing user locale and timezone for more details. |
Date-time picker form inputs
Action callback functions can receive current widget values in the commonEventObject.formInputs field. This includes the user's selected date or time values in date or time picker widgets. However, the structure of the information differs depending on whether the widget was configured as a date-time picker, a date-only picker, or a time-only picker. The structural differences are described in the following table:
Chat event object
The Chat event object is the portion of the overall event object that carries information about a user's interactions with a Chat app. It's only present in an event object if the add-on extends Google Chat.
| Chat | |
|---|---|
chat.user | object (User) The Chat user that interacted with the Chat app. |
chat.space | object (Space) The Chat space where a user interacted with the Chat app. |
chat.eventTime |
|
Union field
| |
chat.messagePayload |
The payload that Chat apps receive from a Message trigger. |
chat.addedToSpacePayload |
The payload that Chat apps receive from an Added to space trigger. |
chat.removedFromSpacePayload |
The payload that Chat apps receive from a Removed from space trigger. |
chat.buttonClickedPayload |
The payload that Chat apps receive when users click a button from a message or card. If a user clicks a button to submit information, the |
chat.widgetUpdatedPayload |
The payload that Chat apps receive when users type text into the multiselect menu of a The |
chat.appCommandPayload |
The payload that Chat apps receive when a user uses a command from the Chat app. |
Payload
Depending on the type of Chat app interaction, the event contains a payload with one or more Chat API resources.
Message payload
MessagePayload chat.messagePayload.messageobject (Message)
The Chat message that triggered the event. chat.messagePayload.spaceobject (Space)
The Chat space in which a user sent the message that invoked the Chat app. chat.messagePayload.configCompleteRedirectUristring
The URL the Chat app should redirect the user to after they complete an authorization or configuration flow outside of Google Chat. For more information, see Connect your Google Workspace add-on to a third-party service.
When administrators install Chat apps, the Added to space payload
AddedToSpacePayload chat.addedToSpacePayload.spaceobject (Space)
The Chat space to which the user added or installed the Chat app. space.adminInstalled field is set to true. chat.addedToSpacePayload.interactionAddboolean
Whether a user adds the Chat app to a space using a message. For example, @mentions the Chat app or uses a command. If true, Chat sends another event object with a messagePayload that contains information about the message. chat.addedToSpacePayload.configCompleteRedirectUristring
The URL the Chat app should redirect the user to after they complete an authorization or configuration flow outside of Google Chat. For more information, see Connect your Google Workspace add-on to a third-party service.
When administrators uninstall Chat apps, the Removed from space payload
RemovedFromSpacePayload chat.removedFromSpacePayload.spaceobject (Space)
The Chat space from which the user removed or uninstalled the Chat app. space.adminInstalled field is set to false.
Enum Value of Button clicked payload
ButtonClickedPayload chat.buttonClickedPayload.messageobject (Message)
The Chat message that contains the button that a user clicked. chat.buttonClickedPayload.spaceobject (Space)
The Chat space where the user clicked a button from a Chat app message. chat.buttonClickedPayload.isDialogEventboolean
Whether the user clicked the button to interact with a dialog. chat.buttonClickedPayload.dialogEventTypeenum (DialogEventType)
If isDialogEvent is true, the type of interaction in a dialog. DialogEventType.dialogEventType can be only one of the following: TYPE_UNSPECIFIEDDefault value. Unspecified. REQUEST_DIALOGA user requests a dialog. For example, they use a command or click a button from a message. SUBMIT_DIALOGA user clicks an interactive element within a dialog. For example, a user fills out information in a dialog and clicks a button to submit the information.
Widget updated payload
WidgetUpdatedPayload chat.widgetUpdatedPayload.spaceobject (Space)
The Chat space where the interaction occurred.
Enum Value of The command ID. Enum Value of App command payload
AppCommandPayload chat.appCommandPayload.appCommandMetadataobject (AppCommandMetadata)
Metadata about which command the user used, and how they triggered the command. chat.appCommandPayload.spaceobject (Space)
The Chat space in which a user used the command. chat.appCommandPayload.threadobject (Thread)
If the interaction occurred in a thread, the Chat thread where the user used the command. chat.appCommandPayload.messageobject (Message)
For slash commands, the message that contains the slash command. chat.appCommandPayload.configCompleteRedirectUristring
If authorization or configuration is required for the command, a URL to redirect the user to after they complete the process outside of Google Chat. chat.appCommandPayload.isDialogEventboolean
Whether the command opens a dialog. chat.appCommandPayload.dialogEventTypeenum (DialogEventType)
The type of interaction with a dialog. DialogEventType.dialogEventType can be only one of the following: TYPE_UNSPECIFIEDDefault value. Unspecified. REQUEST_DIALOGA user requests a dialog. For example, they use a command or click a button from a message. SUBMIT_DIALOGA user clicks an interactive element within a dialog. For example, a user fills out information in a dialog and clicks a button to submit the information. App Command Metadata
AppCommandMetadata chat.appCommandPayload.appCommandMetadata.appCommandId string (int64 format) chat.appCommandPayload.appCommandMetadata.appCommandTypeenum (AppCommandType)
The type of command. AppCommandType.AppCommandType can be only one of the following: APP_COMMAND_TYPE_UNSPECIFIEDDefault value. Unspecified. SLASH_COMMANDA user uses the command by sending a message that begins with a slash /. QUICK_COMMANDThe user selects the command from the Chat menu in the message reply area.
Calendar event object
The Calendar event object is the portion of the overall event object that carries information about a user's calendar and calendar events. It's only present in an event object if the add-on extends Google Calendar.
The following table lists the fields present in the calendarEventObject field of an event object. Fields marked as User-generated data are present in the event object if and only if the data is present in the Calendar event and the add-on sets its addOns.calendar.currentEventAccess manifest field to READ or READ_WRITE.
| Calendar event object | |
|---|---|
calendar.attendees[] | list of attendee objectsUser-generated data. A list of the attendees of the calendar event. |
calendar.calendarId | stringThe calendar ID. |
calendar.capabilities | objectUser-generated data. An object describing the capabilities of the add-on to view or update event information. |
calendar.capabilities.canAddAttendees | booleanUser-generated data. true if the add-on can add new attendees to the event attendee list; false otherwise. |
calendar.capabilities.canSeeAttendees | booleanUser-generated data. true if the add-on can read the event attendee list; false otherwise. |
calendar.capabilities.canSeeConferenceData | booleanUser-generated data. true if the add-on can read the event conference data; false otherwise. |
calendar.capabilities.canSetConferenceData | booleanUser-generated data. true if the add-on can update the event conference data; false otherwise. |
calendar.capabilities.canAddAttachments | booleanUser-generated data. true if the add-on can add new attachments to the event; false otherwise. |
calendar.conferenceData | Conference data objectUser-generated data. An object representing any conference data associated with this event, such as Google Meet conference details. |
calendar.id | stringThe event ID. |
calendar.organizer | objectAn object representing the organizer of the event. |
calendar.organizer.email | stringThe event organizer's email address. |
calendar.recurringEventId | stringThe ID of a recurring event. |
Attendee
Attendee objects carry information about individual attendees to Google Calendar events. This information is present in the event object if and only if the data is present in the Calendar event and the add-on sets its addOns.calendar.currentEventAccess manifest field to READ or READ_WRITE.
| Attendee object | |
|---|---|
attendee.additionalGuests | numberThe number of additional guests the attendee had indicated they are bringing. Defaults to zero. |
attendee.comment | stringThe attendee's response comment, if any. |
attendee.displayName | stringThe attendee displayed name. |
attendee.email | stringThe attendee email address. |
attendee.optional | booleantrue if the attendance for this attendee is marked as optional; false otherwise. |
attendee.organizer | booleantrue if the attendee is an organizer for this event. |
attendee.resource | booleantrue if the attendee represents a resource, such as room or piece of equipment; false otherwise. |
attendee.responseStatus | stringThe attendee's response status. Possible values include the following:
|
attendee.self | booleantrue if this attendee represents the calendar in which this event appears; false otherwise. |
Conference data
Conference data objects carry information about conferences that are attached to Google Calendar events. These can be Google conference solutions, such as Google Meet, or third-party conferences. This information is present in the event object if and only if the data is present in the Calendar event and the add-on sets its addOns.calendar.currentEventAccess manifest field to READ or READ_WRITE.
| Conference data object | |
|---|---|
conferenceData.conferenceId | stringThe ID of the conference. This ID is meant to allow applications to keep track of conferences; you shouldn't display this ID to users. |
conferenceData.conferenceSolution | objectAn object representing the conference solution, such as Hangouts or Google Meet. |
conferenceData.conferenceSolution.iconUri | stringThe URI for the user-visible icon representing this conference solution. |
conferenceData.conferenceSolution.key | objectThe key which uniquely identifies the conference solution for this event. |
conferenceData.conferenceSolution.key.type | stringThe conference solution type. Possible values include the following:
|
conferenceData.conferenceSolution.name | stringThe user-visible name of this conference solution (not localized). |
conferenceData.entryPoints[] | list of entry point objects The list of conference entry points, such as URLs or phone numbers. |
conferenceData.notes | stringAdditional notes (such as instructions from the domain administrator or legal notices) about the conference to display to the user. Can contain HTML. The maximum length is 2048 characters. |
conferenceData.parameters | objectAn object containing a map of defined parameter data for use by the add-on. |
conferenceData.parameters.addOnParameters | objectA map of parameter string keys and values. These keys and values are defined by the add-on developer to attach information to a specific conference for the add-on's use. |
Entry point
Entry point objects carry information about the established means of accessing a given conference, such as by phone or video. This information is present in the event object if and only if the data is present in the Calendar event and the add-on sets its addOns.calendar.currentEventAccess manifest field to READ or READ_WRITE.
| Entry point object | |
|---|---|
entryPoint.accessCode | stringThe access code used to access the conference. The maximum length is 128 characters. Conference providers typically only use a subset of { accessCode, meetingCode, passcode, password, pin} to provide access to conferences. Match and only ever display the fields the conference provider uses. |
entryPoint.entryPointFeatures | listFeatures of the entry point. Currently these features only apply to phone entry points:
|
entryPoint.entryPointType | stringThe type of entry point. Possible values are the following:
|
entryPoint.label | stringThe user-visible label for the entry point URI (not localized). |
entryPoint.meetingCode | stringThe meeting code used to access the conference. The maximum length is 128 characters. Conference providers typically only use a subset of { accessCode, meetingCode, passcode, password, pin} to provide access to conferences. Match and only ever display the fields the conference provider uses. |
entryPoint.passcode | stringThe passcode used to access the conference. The maximum length is 128 characters. Conference providers typically only use a subset of { accessCode, meetingCode, passcode, password, pin} to provide access to conferences. Match and only ever display the fields the conference provider uses. |
entryPoint.password | stringThe password used to access the conference. The maximum length is 128 characters. Conference providers typically only use a subset of { accessCode, meetingCode, passcode, password, pin} to provide access to conferences. Match and only ever display the fields the conference provider uses. |
entryPoint.pin | stringThe PIN used to access the conference. The maximum length is 128 characters. Conference providers typically only use a subset of { accessCode, meetingCode, passcode, password, pin} to provide access to conferences. Match and only ever display the fields the conference provider uses. |
entryPoint.regionCode | stringRegion code of the phone number. Needed by users if the URI doesn't include a country code. Values are based on the public CLDR list of region codes. |
entryPoint.uri | stringThe URI of the entry point. The maximum length is 1300 characters. The formatting depends on the entry point type:
|
Drive event object
The Drive event object is the portion of the overall event object that carries information about a user's Google Drive and its contents. It's only present in an event object if the add-on extends Google Drive.
| Drive event object | |
|---|---|
drive.activeCursorItem | Drive item objectThe Drive item currently active. |
drive.selectedItems[] | list of Drive item objectsA list of items (files or folders) selected in Drive. |
Drive item
Drive item objects carry information about specific Drive items, such as files or folders.
| Drive item object | |
|---|---|
item.addonHasFileScopePermission | booleanIf true, the add-on has requested and received https://www.googleapis.com/auth/drive.file scope authorization for this item; otherwise this field is false. |
item.id | stringThe ID of the selected item. |
item.iconUrl | stringThe URL of the icon that represents the selected item. |
item.mimeType | stringThe MIME type of the selected item. |
item.title | stringThe title of the selected item. |
Gmail event object
The Gmail event object is the portion of the overall event object that carries information about a user's Gmail messages. It's only present in an event object if the host application is Gmail.
| Gmail event object | |
|---|---|
gmail.accessToken | stringThe Gmail-specific access token. You can use this token with the GmailApp.setCurrentMessageAccessToken(accessToken) method to grant your add-on temporary access to a user's currently open Gmail message or let your add-on compose new drafts. |
gmail.bccRecipients[] | list of stringsDisabled by default. The list of "BCC:" recipient email addresses currently included in a draft the add-on is composing. To turn on this field, you must set the addOns.gmail.composeTrigger.draftAccess field in your manifest to METADATA. |
gmail.ccRecipients[] | list of stringsDisabled by default. The list of "CC:" recipient email addresses currently included in a draft the add-on is composing. To turn on this field, you must set the addOns.gmail.composeTrigger.draftAccess field in your manifest to METADATA. |
gmail.messageId | stringThe ID of the currently open Gmail message. |
gmail.threadId | stringThe currently open Gmail thread ID. |
gmail.toRecipients[] | list of stringsDisabled by default. The list of "To:" recipient email addresses currently included in a draft the add-on is composing. To turn on this field, you must set the addOns.gmail.composeTrigger.draftAccess field in your manifest to METADATA. |
Docs event object
The Docs event object is the portion of the overall event object that carries information about a user's document and its contents. It's only present in an event object if the add-on extends Google Docs.
| Docs event object | |
|---|---|
docs.id | stringOnly present if the https://www.googleapis.com/auth/drive.file scope has been authorized by the user.The ID of the document open in the Docs UI. |
docs.title | stringOnly present if the https://www.googleapis.com/auth/drive.file scope has been authorized by the user.The title of the document open in the Docs UI. |
docs.addonHasFileScopePermission | booleanIf true, the add-on has requested and received https://www.googleapis.com/auth/drive.file scope authorization for the document open in the Docs UI; otherwise this field is false. |
docs.matchedUrl.url | string Only present if the following conditions are met:
The URL of the link that generates a preview in Google Docs. To use this field, you must configure the LinkPreviewTriggers in your add-on’s manifest. See Preview links with smart chips for more details. Example payload for when a user previews the link "docs" : { "matchedUrl" : { "url" : "https://www.example.com/12345" } } |
Sheets event object
The Sheets event object is the portion of the overall event object that carries information about a user's document and its contents. It's only present in an event object if the add-on extends Google Sheets.
| Sheets event object | |
|---|---|
sheets.id | stringOnly present if the https://www.googleapis.com/auth/drive.file scope has been authorized by the user. The ID of the spreadsheet open in the Sheets UI. |
sheets.title | stringOnly present if the https://www.googleapis.com/auth/drive.file scope has been authorized by the user. The title of the spreadsheet open in the Sheets UI. |
sheets.addonHasFileScopePermission | booleanIf true, the add-on has requested and received https://www.googleapis.com/auth/drive.file scope authorization for the spreadsheet open in the Sheets UI; otherwise this field is false. |
sheets.matchedUrl.url | string Only present if the following conditions are met:
The URL of the link that generates a preview in Google Sheets. To use this field, you must configure the LinkPreviewTriggers in your add-on’s manifest. See Preview links with smart chips for more details. Example payload for when a user previews the link "sheets" : { "matchedUrl" : { "url" : "https://www.example.com/12345" } } |
Slides event object
The Slides event object is the portion of the overall event object that carries information about a user's document and its contents. It's only present in an event object if the add-on extends Google Slides.
| Slides event object | |
|---|---|
slides.id | stringOnly present if the https://www.googleapis.com/auth/drive.file scope has been authorized by the user. The ID of the presentation open in the Slides UI. |
slides.title | stringOnly present if the https://www.googleapis.com/auth/drive.file scope has been authorized by the user. The title of the presentation open in the Slides UI. |
slides.addonHasFileScopePermission | booleanIf true, the add-on has requested and received https://www.googleapis.com/auth/drive.file scope authorization for the presentation open in the Slides UI; otherwise this field is false. |
slides.matchedUrl.url | string Only present if the following conditions are met:
The URL of the link that generates a preview in Google Slides. To use this field, you must configure the LinkPreviewTriggers in your add-on’s manifest. See Preview links with smart chips for more details. Example payload for when a user previews the link "slides" : { "matchedUrl" : { "url" : "https://www.example.com/12345" } } |