A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/workspace/chat/quickstart/apps-script-app below:

Build a Google Chat app with Google Apps Script

Skip to main content Build a Google Chat app with Google Apps Script

Stay organized with collections Save and categorize content based on your preferences.

Note: This guide explains how to build an interactive Chat app using Chat API interaction events. You can also build your Chat app as a Google Workspace add-on. To learn about which framework to use, see Build an interactive Google Chat app.

Create a Google Chat app that you can directly message and that responds by echoing your messages.

The following diagram shows the architecture and messaging pattern:

In the preceding diagram, a user interacting with an Apps Script Chat app has the following flow of information:

  1. A user sends a message to a Chat app, either in a direct message or in a Chat space.
  2. The Chat app logic that's implemented in Apps Script, which resides in Google Cloud, receives and processes the message.
  3. Optionally, the Chat app logic can integrate with Google Workspace services, such as a Calendar or Sheets, or other Google Services, such as Google Maps or YouTube.
  4. The Chat app logic sends a response back to the Chat app service in Chat.
  5. The response is delivered to the user.
Objectives Prerequisites Set up your environment Open your Cloud project in the Google Cloud console

If it's not open already, open the Cloud project that you intend to use for this sample:

  1. In the Google Cloud console, go to the Select a project page.

    Select a Cloud project

  2. Select the Google Cloud project you want to use. Or, click Create project and follow the on-screen instructions. If you create a Google Cloud project, you might need to turn on billing for the project.
Turn on the Chat API

Before using Google APIs, you need to turn them on in a Google Cloud project. You can turn on one or more APIs in a single Google Cloud project.

Configure the OAuth consent screen

All apps using OAuth 2.0 require a consent screen configuration. Configuring your app's OAuth consent screen defines what is displayed to users and app reviewers, and registers your app so you can publish it later.

  1. In the Google Cloud console, go to Menu menu > Google Auth platform > Branding.

    Go to Branding

  2. If you have already configured the Google Auth platform, you can configure the following OAuth Consent Screen settings in Branding, Audience, and Data Access. If you see a message that says Google Auth platform not configured yet, click Get Started:
    1. Under App Information, in App name, enter a name for the app.
    2. In User support email, choose a support email address where users can contact you if they have questions about their consent.
    3. Click Next.
    4. Under Audience, select Internal.
    5. Click Next.
    6. Under Contact Information, enter an Email address where you can be notified about any changes to your project.
    7. Click Next.
    8. Under Finish, review the Google API Services User Data Policy and if you agree, select I agree to the Google API Services: User Data Policy.
    9. Click Continue.
    10. Click Create.
  3. For now, you can skip adding scopes. In the future, when you create an app for use outside of your Google Workspace organization, you must change the User type to External. Then add the authorization scopes that your app requires. To learn more, see the full Configure OAuth consent guide.
Set up the script

To set up the script, you use a template and then set your Cloud project in Apps Script.

Create the script from the template
  1. Go to the Apps Script Getting Started page.
  2. Click the Chat App template at the top of the page.
  3. Click Untitled project, type Quickstart app, and click Rename.
Copy the Cloud project number
  1. In the Google Cloud console, go to Menu menu > IAM & Admin > Settings.

    Go to IAM & Admin Settings

  2. In the Project number field, copy the value.
Set the Apps Script project's Cloud project
  1. In the Chat app Apps Script project, click Project Settings .
  2. Under Google Cloud Platform (GCP) Project, click Change project.
  3. In GCP project number, paste the Google Cloud project number.
  4. Click Set project.

You now have working app code that you can try out (as described in the following steps) and then customize to meet your requirements.

Make sure that you're signed in to the correct Google Account when you open the Apps Script template. The current account can sometimes switch to your default account without you noticing.

Create a test deployment

You need a deployment ID for this Apps Script project, so that you can use it in the next step.

To get the head deployment ID, do the following:

  1. In the Chat app Apps Script project, click Deploy > Test deployments.
  2. Copy the Head deployment ID for use in a later step and click Done.
Publish the Chat app

Publish the Chat app from the console.

  1. In the console, search for Google Chat API, and click Google Chat API.
  2. Click Manage.
  3. Click Configuration and set up the Chat app:

    1. Clear Build this Chat app as a Google Workspace add-on. A dialog opens asking you to confirm. In the dialog, click Disable.
    2. In the App name field, enter Quickstart app.
    3. In the Avatar URL field, enter https://developers.google.com/chat/images/quickstart-app-avatar.png.
    4. In the Description field, enter Quickstart app.
    5. Under Functionality, select Join spaces and group conversations.
    6. Under Connection settings, select Apps Script.
    7. In the Deployment ID field, paste the Head deployment ID that you previously copied.
    8. Under Visibility, select Specific people and groups in your domain, and enter your email.
  4. Click Save.

The Chat app is ready to respond to messages.

Test the Chat app

To test your Chat app, open a direct message space with the Chat app and send a message:

  1. Open Google Chat using the Google Workspace account that you provided when you added yourself as a trusted tester.

    Go to Google Chat

  2. Click add New chat.
  3. In the Add 1 or more people field, type the name of your Chat app.
  4. Select your Chat app from the results. A direct message opens.

    Note: If you don't see your Chat app in the list of results, ensure that you've included your Google Workspace account in the Visibility settings of the Chat API Configuration page in the Google Cloud console.
  5. In the new direct message with the app, type Hello and press enter.

    The Chat app thanks you for adding it and echoes your message.

To add trusted testers and learn more about testing interactive features, see Test interactive features for Google Chat apps.

Troubleshoot

When a Google Chat app or card returns an error, the Chat interface surfaces a message saying "Something went wrong." or "Unable to process your request." Sometimes the Chat UI doesn't display any error message, but the Chat app or card produces an unexpected result; for example, a card message might not appear.

Although an error message might not display in the Chat UI, descriptive error messages and log data are available to help you fix errors when error logging for Chat apps is turned on. For help viewing, debugging, and fixing errors, see Troubleshoot and fix Google Chat errors.

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this tutorial, we recommend that you delete the Cloud project.

Caution: Deleting a project has the following effects:

If you plan to explore multiple tutorials and quickstarts, reusing projects can help you avoid exceeding project quota limits.

  1. In the Google Cloud console, go to the Manage resources page. Click Menu menu > IAM & Admin > Manage Resources.

    Go to Resource Manager

  2. In the project list, select the project you want to delete and then click Delete delete.
  3. In the dialog, type the project ID and then click Shut down to delete the project.
Next steps

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["Create a Google Chat app that echoes user messages using Apps Script and Google Cloud."],["This involves setting up your environment, configuring the script, publishing the app, and testing its functionality."],["Prerequisites include a Google Workspace account and a Google Cloud project."],["The app is designed to receive direct messages and participate in spaces, integrating with various Google services as needed."],["You can find troubleshooting information and cleanup instructions in the provided documentation."]]],["This guide details how to create a Google Chat app that echoes messages. Key actions include: setting up a Google Cloud environment and enabling the Chat API; configuring the OAuth consent screen; creating an Apps Script project from a template and linking it to the Cloud project; publishing the app with a deployment ID; and testing the app by sending a direct message. It also covers troubleshooting, cleanup, and suggests next steps for developing more advanced features.\n"]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4