Google Chat Samples

repository·main·Indexed 20 days ago

https://github.com/googleworkspace/google-chat-samples

A collection of code samples for building interactive Google Chat apps. The repository covers various integration patterns, including synchronous HTTP endpoints, asynchronous Pub/Sub messaging, and complex card interactions. Featured samples include an Attendance app, Avatar app, Incident Response app with Vertex AI Gemini integration, Issue Management app, and an OOO (Out of Office) app, with implementations utilizing Google Apps Script and Cloud Functions.

Tokens
38.2K
Snippets
97
Records
154
Agent score
69%

What's inside google-chat-samples

  1. Overview of Google Chat app sample types

    main

    This repository provides various implementation patterns for Google Chat apps. Each sample folder contains language-specific implementations (Node.js, Python, Java, Apps Script). Key sample types include:

    • Basic app: An HTTP endpoint app (using Google App Engine) that receives event notices/messages and responds synchronously with text.
    • Avatar app: An HTTP endpoint app (using Google Cloud Run Functions) that responds synchronously with card-formatted responses.
    • Pub/Sub app: An app that uses Google Cloud Pub/Sub to receive messages and responds to Google Chat asynchronously.
    • Vote app: Demonstrates updating interactive cards via user voting (text or image-based).
    • Contact form app: Demonstrates handling input forms, dialogs, and action parameters using cards.
    • Preview link app: Shows how to use preview links to provide metadata for links in messages.
    • App home app: Handles app home event notices and responds synchronously with cards (includes initialization and updates).
    • Selection input app: Demonstrates using external data sources to dynamically populate selection items in card widgets.
    • User Auth app: Demonstrates obtaining authorization to call the Chat API with user credentials and storing tokens in a database.
    • Webhook app: Demonstrates sending messages to Google Chat using incoming webhooks.
  2. Overview of the Google Chat AI Knowledge Assistant app

    main

    The AI Knowledge Assistant is a Google Chat app that uses generative AI (Vertex AI with Gemini) to answer questions based on conversation history within Chat spaces.

    Key Features:

    • Real-time Knowledge Retrieval: Uses the Google Workspace Events API and Pub/Sub to monitor conversations in real time, allowing it to answer questions even when not explicitly @mentioned.
    • Dynamic Knowledge Base: It treats all messages in a space as a data source. It searches for existing answers first; if none are found, it @mentions a space manager to request an answer.
    • Continuous Learning: The app adapts as it continuously processes new conversations in the spaces where it is added.

    Architecture:

  3. Overview of the Cloud Functions avatar app

    main

    The avatar-app is a Google Chat application implemented using Google Cloud Functions. It demonstrates two primary interaction patterns:

    1. Message Response: Responding to simple text messages by returning the user's avatar.
    2. Slash Commands: Providing more detailed information about the app when triggered via a slash command.

    This sample is useful for developers wanting to learn how to deploy a lightweight Google Chat app using a serverless architecture.

  4. Overview of the Google Chat Incident Response app

    main

    The Google Chat Incident Response app is an Apps Script-based sample that demonstrates how to automate technical incident workflows. It consists of two primary components:

    1. Web Page: A simulation interface where users enter incident details (title, description, and responder email addresses).
    2. Chat App: An automated agent that receives data from the web page to:
      • Create a new Chat space.
      • Add specified responders as members to the space.
      • Post the incident description as the initial message.

    Post-Mortem Automation: Once an incident is resolved, the app supports a slash command that automatically generates a Google Doc post-mortem. This document includes:

    • A user-provided description of the resolution.
    • A full transcript of the Chat conversation.
    • An automated summary of the conversation generated via Vertex AI.
  5. Overview of the Google Chat Project Management app

    main

    The Project Management app is a Google Chat application designed for real-time team project management. It is implemented as a Google Cloud Function using a Node.js runtime.

    Key features and integrations include:

    • Interaction Handling: Responds to interaction events from Google Chat.
    • AI Capabilities: Uses Vertex AI to assist teams in writing user stories (feature descriptions from a user perspective).
    • Data Persistence: Stores user stories in a Firestore database.
  6. Overview of the Issue Management App

    main

    The Issue Management App is a Google Chat application designed to demonstrate advanced integration patterns. It is specifically featured in the Build apps for Google Chat with Gemini codelab.

    Key technologies and features demonstrated by this app include:

    • Vertex AI Gemini-powered models: Integration of generative AI capabilities.
    • App Home cards: Building dedicated landing pages for your Chat app.
    • Google Workspace Chat events: Handling various interaction events within the Chat interface.
    • Accessory widgets: Using interactive elements within the Chat UI.
  7. Build a Google Chat app with card interactions

    main

    This sample demonstrates how to build a Google Chat app that leverages interactive UI elements. It specifically covers the implementation of:

    • Slash commands: Triggering app logic via / commands.
    • Cards: Using structured UI components for messaging.
    • Dialogs: Displaying pop-up windows for user interaction.
    • Form inputs: Collecting data from users within the app.
    • Action parameters: Passing data through user interactions.

    For deeper implementation details on the underlying Google Chat features, refer to the official documentation on dialogs and forms.