This section describes the format of events that your app receives from Google Chat.
Event fields
When your app receives an event from Google Chat, the event includes a request body: this is the JSON payload that represents the event. This payload contains elements that are common to all event types, as well as elements that are specific to the event type. The following diagram shows the fields that might be present in the payload:
Common event fields
Common fields are always provided in the payload of all events, regardless of type.
Field | Type | Description |
---|---|---|
type |
String | The type of the event the app is receiving. |
eventTime |
String | The timestamp (formatted according to RFC 3339) indicating when the event was dispatched. |
Type-specific event fields
Additional fields might be present in the request payload, if they are applicable to the event type.
Field | Type | Description | Event type |
---|---|---|---|
message |
Message | The message related to the event. | Message, added to space. |
space |
Space | The space related to the event. | Message, added to space, removed from space. |
user |
User | The user related to the event. | Message, added to space, removed from space. |
thread |
Thread | The thread a message belongs to. | Message events only. |
Event types
This section describes the types of events that your app might receive, with examples of each type.
ADDED_TO_SPACE
This event indicates that your app was added to a space. Apps typically respond to this event by posting some kind of welcome message in a new thread in the space.
The following JSON example shows the request body for an ADDED_TO_SPACE
event:
{
"type": "ADDED_TO_SPACE",
"eventTime": "2017-03-02T19:02:59.910959Z",
"space": {
"name": "spaces/AAAAAAAAAAA",
"displayName": "Customer Support Superstars",
"type": "ROOM"
},
"user": {
"name": "users/12345678901234567890",
"displayName": "Izumi",
"avatarUrl": "https://lh3.googleusercontent.com/.../photo.jpg",
"email": "izumi@example.com"
}
}
REMOVED_FROM_SPACE
This event indicates that your app was removed from a space. Apps don't respond to this event, because they have already been removed.
The following JSON example shows the request body for an REMOVED_FROM_SPACE
event:
{
"type": "REMOVED_FROM_SPACE",
"eventTime": "2017-03-02T19:02:59.910959Z",
"space": {
"name": "spaces/AAAAAAAAAAA",
"type": "DM"
},
"user": {
"name": "users/12345678901234567890",
"displayName": "Izumi,
"avatarUrl": "https://lh3.googleusercontent.com/.../photo.jpg",
"email": "izumi@example.com"
}
}
MESSAGE
This event represents a message sent to the app.
The message details are stored as fields within the message
field.
Response behavior: posts a message in the same thread as the original user message.
An example payload:
{
"type": "MESSAGE",
"eventTime": "2017-03-02T19:02:59.910959Z",
"space": {
"name": "spaces/AAAAAAAAAAA",
"displayName": "Customer Support Superstars",
"type": "ROOM"
},
"message": {
"name": "spaces/AAAAAAAAAAA/messages/CCCCCCCCCCC",
"sender": {
"name": "users/12345678901234567890",
"displayName": "Izumi",
"avatarUrl": "https://lh3.googleusercontent.com/.../photo.jpg",
"email": "izumi@example.com"
},
"createTime": "2017-03-02T19:02:59.910959Z",
"text": "@TestBot Create ticket.",
"argumentText": " Create ticket.",
"thread": {
"name": "spaces/AAAAAAAAAAA/threads/BBBBBBBBBBB"
},
"annotations": [
{
"length": 8,
"startIndex": 0,
"userMention": {
"type": "MENTION",
"user": {
"avatarUrl": "https://.../avatar.png",
"displayName": "TestBot",
"name": "users/1234567890987654321",
"type": "BOT"
}
},
"type": "USER_MENTION"
}
],
"attachment": [
{
"name": "spaces/5o6pDgAAAAE/messages/Ohu1LlUVcS8.Ohu1LlUVcS8/attachments/AATUf-Iz7d8kySEdRRZd-dznqBk3",
"content_name": "solar.png",
"content_type": "image/png",
"drive_data_ref": {
"drive_file_id": "H1HqaqRuH2Pfd_TOa1fF2_ltwDlV_yKRrr"
},
"source": "DRIVE_FILE"
}
]
},
"user": {
"name": "users/12345678901234567890",
"displayName": "Izumi",
"avatarUrl": "https://lh3.googleusercontent.com/.../photo.jpg",
"email": "izumi@example.com"
}
}