Anatomy of Chat apps - Advanced interaction
Advanced Interaction Elements in Google Chat Apps
Overview of Advanced Interaction Elements
- Chanel, a Developer Advocate at Google, introduces four advanced interaction elements for Google Chat apps: slash commands, dialogs, preview links, and message attachments.
- Slash commands allow users to interact with app features; for example, typing
/helpcan display available commands and their descriptions.
Slash Commands
- In the Google Cloud Console, developers can configure slash commands by defining a name, unique identifier, and description.
- When invoked, an additional field is attached to the message indicating the selected command ID and its annotation for easier handling within the app.
Dialogs
- Dialogs are useful for collecting structured information or configuring settings; they can be created using the Card Builder tool.
- Sequential dialogs help users complete multi-step processes. The event received from Google Chat indicates whether a dialog was opened or canceled.
Handling Dialog Events
- Upon form submission in a dialog, a
CARD_CLICKEDevent is sent with relevant data. The app must process this data accordingly.
- If required fields are missing (e.g., "name"), the app returns an error; otherwise, it acknowledges receipt and closes the dialog.
Link Previewing
- Users often share links in chat; link previewing allows apps to attach cards that provide additional information about these links.
- Cards include interactive elements like buttons and can be updated based on user interactions after sending messages containing links.
Configuring Link Previews
- Developers can enable link previews in the Chat API configuration page by registering specific URL patterns.
- When users click buttons on preview cards (e.g., "Assign to me"), apps update these cards dynamically based on user actions.
Message Attachments
- Users can send attachments such as files from Google Drive. The JSON representation of attachments includes details about their source type (e.g., UPLOADED_CONTENT).
- For Google Drive files, attachment references include file IDs necessary for retrieval via the Media API.
Conclusion & Further Learning