Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Google Chat basic app

This code sample creates a simple Google Chat app that responds to events and messages from a space. The sample is built using Java 17 and Spring Boot on Google App Engine, Standard Environment.

Deploy the sample

  1. Follow the steps in Setting Up Your Development Environment to install Java and the Google Cloud SDK.

  2. Follow the steps in Using Maven and the App Engine Plugin to install Maven.

  3. Follow the steps in Setting Up Your GCP Resources to create a project and enable App Engine.

  4. Run the following command to deploy the app:

    mvn clean package appengine:deploy -Dapp.deploy.projectId=YOUR_PROJECT_ID
    

Configure the app for Google Chat

  1. To configure the app to respond to @mentions in Google Chat, follow the steps to enable the API in Publishing apps.
  2. When configuring the app on the Configuration tab on the Google Chat API page, enter the URL for the deployed version of the app into the App URL text box.

Interact with the app

Either add and @mention the app in a space or in a direct mention to engage with the app.

When added to a space or messaged, the app will respond with a simple reply.

Start the sample locally

  1. Run the sample.
    mvn spring-boot:run
    

To verify that the sample is running and responds with the correct data to incoming requests, run the following command from the terminal:

curl -X POST -H 'Content-Type: application/json' 'http://localhost:8080' -d '{ "type": "MESSAGE", "message": { "text": "Hello!", "sender": { "displayName": "me"}}, "space": { "displayName": "some space"}}'

Optional: Enable Google Chat app request verification

This code sample supports request verification but it's disabled by default. To enable it you need to:

  1. Set the constant AUDIENCE_TYPE to APP_URL or PROJECT_NUMBER in the file App.java depending on the type of authentication audience you want to use.

  2. Set the constant AUDIENCE in the file App.java to the app URL or project number depending on what you specified in the previous step.

  3. Set the parameter Authentication Audience under Connection settings from the Google Chat app configuration to the same audience type you specified in the AUDIENCE_TYPE constant.

  4. Redeploy or restart the sample in AppEngine or locally and interact with the app as described in other sections.

You can learn more about Google Chat app request verification from the guide Verify requests from Google Chat.