Interactions between Google Chat and apps take place using messages in the context of particular spaces. For example, an app may send some simple text (a type of message) into a specific chat space (a type of space).
Messages between Google Chat and an app implementation follow a defined message format, where each message consists of a JSON object whose components specify the user ID, style, content, and other aspects of the message.
There are several kinds of messages used in the interaction of apps with Google Chat.
Messages from Google Chat to an app are known as events, and can be of several different types.
Messages from an app to Google Chat can have either or both of two kinds of content:
- Simple text contains plain text content with limited text formatting.
- Cards define the format, content, and behavior of cards to be displayed in the target space.
A space in Google Chat is a generalization of chat spaces and direct messages. While each type of space has specific properties (for example, a chat space is visible to multiple users, while a direct message is not) the general concept of a space is often used.
For example, an app can send a message to a space, regardless of what kind of space it is. However, there can be constraints on that message that affect how it is handled, depending on the target space's specific type.
In addition to simple text replies, apps can also display more complex UIs in the form of cards.
In this example, a project management app replies to a query by building a list of data, wrapping it with header information into a card data structure, and returning it to the chat. Google Chat then parses the data and displays the card.