Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create a chat app from a template
/ 50
Configure the user consent screen
/ 50
Create a chat app from a template
/ 50
Configure the user consent screen
/ 50
Google Chat apps provide easy-to-use access points to your organization's data and services. Users can converse with apps within a chat experience. One way to create a Google Chat app is to use Google Apps Script. Apps Script also gives you easy access to other Google services like Drive, Gmail, Calendar, Docs, Sheets, and much more.
In this lab, you use Google Apps Script to create a simple Google Chat app with the converged Google Workspace Add-ons architecture.
In this lab, you learn how to perform the following tasks:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the right is the Lab setup and access panel with the following:
Note that the lab timer is located near the top of the page, showing the remaining time.
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab setup and access panel.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab setup and access panel.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
To implement your Chat app, create a new Google Apps Script project using the Chat app template.
Click the Google Apps Script homepage link to open the Google Apps Script online editor.
Under Google Workspace add-on starters, click Chat app (Intermediate version).
Click Untitled project (the current name).
In the Edit project name dialog, rename the project to Friendly Bot, and then click Rename.
Google Chat apps built with Google Apps Script operate on the converged Google Workspace Add-ons (Chaddons) event-driven architecture. The interaction between the user, Google Chat, and the Google Workspace Add-on follows a structured flow:
eventTime and message.createTime formatted in ISO 8601 UTC strings, for example 2026-08-06T14:30:00.000Z).In the converged Google Workspace Add-ons model, Google Chat dispatches interactions to specific event handler functions defined in your script:
ADDED_TO_SPACE: Triggers when a user adds the Chat app to a space or starts a new direct message (DM). In Apps Script, you define the onAddedToSpace(event) function to return a greeting or onboarding card.REMOVED_FROM_SPACE: Triggers when a user removes the Chat app from a space or direct message. In Apps Script, you define the onRemovedFromSpace(event) function to perform cleanup logic. This handler does not post a response back to Google Chat.MESSAGE: Triggers when a user sends a message to the Chat app in a direct message or @mentions the app in a space. In Apps Script, you define the onMessage(event) function to parse the message payload and respond.CARD_CLICKED: Triggers when a user interacts with interactive UI widgets (such as buttons or form inputs) within a card message. In Apps Script, you define the onCardClick(event) function or custom action callbacks to handle user actions.In earlier legacy Chat bots, timestamps were delivered as Unix epoch milliseconds (such as event.eventTime.msSinceEpoch). In the converged Google Workspace Add-ons (Chaddons) event schema, all timestamps are standardized as ISO 8601 date-time strings (e.g., "2026-08-06T14:30:00.000Z"). This structure provides uniform timestamp formatting across Google Workspace Add-ons and the Google Chat API, accessible directly on properties such as event.eventTime and event.message.createTime.
The Chat app template pre-populates Code.gs with the event handler functions configured for the converged Google Workspace Add-on architecture.
In the Apps Script online editor, in the left navigation pane, click Code.gs to open the script file.
Review the pre-populated event handler functions:
onMessage(event): Handles the MESSAGE event when a user sends a message to the app. The function reads the user's message text and metadata from the event object, inspects the ISO date-time timestamp, and returns a formatted text reply.onAddedToSpace(event): Handles the ADDED_TO_SPACE event when the app is added to a space or direct message, returning a greeting message.onRemovedFromSpace(event): Handles the REMOVED_FROM_SPACE event when the app is removed from a space.Before you can run and test the Chat app, the Google Chat API must be enabled for your Google Cloud project, and your Chat app must be published.
In this task, you complete the configuration steps to publish the Chat app: configure the OAuth consent screen, update the Apps Script application to reference your Google Cloud project, and configure the Google Chat API to publish the app for testing.
In the Google Cloud console, click the Navigation menu () in the upper left, and navigate to APIs & Services > OAuth consent screen.
Click Get Started.
For Project configuration page, for App Information configure the following, and then click Next:
| Field | Value |
|---|---|
| App name | Friendly Bot |
| User support email | Select the email ID |
For Audience, select Internal and click Next.
For Contact Information, provide the email address
Accept the policy, and click Continue. Then, click Create.
Click Check my progress to verify the objective.
From the Navigation menu (), click Cloud Overview > Dashboard.
In the dashboard, locate the Project Info section.
Record the Project number to use in the next step to configure your project.
Return to the Apps Script editor, and navigate to the Project Settings for the Friendly Bot project ().
Under Google Cloud Platform (GCP) Project, click Change project.
For GCP Project number, enter the project number that you copied earlier. Then, click Set project.
In the Apps Script editor, get the Head Deployment ID for the test deployment by clicking Deploy > Test deployments (top-right of the screen), and then clicking Copy next to Head Deployment ID.
In the Google Cloud console, navigate to Navigation menu () > APIs & Services > Library.
In the Library, search for Google Chat API, and select the API from the list of results.
The Google Chat API should already be enabled in this project. If it is not enabled, click Enable.
Click Manage then click on Configuration tab for the Google Chat API.
In the Configuration dialog, configure the fields with the following values:
| Field | Value |
|---|---|
| App name | Friendly Bot |
| Avatar URL | https://goo.gl/kv2ENA |
| Description | Apps Script lab app |
| Functionality | Enable the Join spaces and group conversations checkbox |
| Connection settings | Select Apps Script, and then paste the Head Deployment ID into the Deployment ID box. |
| Visibility |
Click Save.
After the changes are saved, scroll to the top of the Configuration dialog to update the App Status to LIVE – available to users.
You may have to refresh the page to see the App Status field. If the value for App Status is already set to LIVE – available to users, you can leave that value, but be sure to save the page again in the next step.
Complete the following steps to test your app in Google Chat:
Click the Google Chat link to open Google Chat.
Select Start a chat (or click the plus icon next to Direct messages).
In the search box, enter Friendly Bot.
From the results, select Friendly Bot and click Install app for the installation app pop-up (Apps Script lab app) to start a direct message.
When the direct message thread opens, verify that you receive a greeting message from the Chat app thanking you for adding it to a direct message:
This response is initiated by the function named onAddedToSpace, which responds to the ADDED_TO_SPACE event when the app is added to a chat space or direct message.
In the message box, enter a message for the app, such as Hello app!, and press ENTER.
Verify that you receive a reply from the Chat app repeating your message, such as:
This response is initiated by the function named onMessage, which parses the MESSAGE event and ISO date-time timestamp when a user sends a message to the Chat app.
You have successfully created, configured, and tested a Google Chat app using Google Apps Script with the converged Google Workspace Add-ons architecture!
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated August 7, 2026
Lab Last Tested August 7, 2026
Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We can notify you via email when it becomes available
Great!
We can contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one