This code sample creates a Google Chat vote app that allows users to vote on a message. The sample is built using Java 17 and Spring Boot on Google App Engine, Standard Environment.
-
Follow the steps in Setting Up Your Development Environment to install Java and the Google Cloud SDK.
-
Follow the steps in Using Maven and the App Engine Plugin to install Maven.
-
Follow the steps in Setting Up Your GCP Resources to create a project and enable App Engine.
-
Run the following command to deploy the app:
mvn clean package appengine:deploy -Dapp.deploy.projectId=YOUR_PROJECT_ID
- To configure the app to respond to @mentions in Google Chat, follow the steps to enable the API in Publishing apps.
- 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.
Either add or @mention the app in a space or in a direct mention to start a new vote session.
You can specify the statement to start a new vote session for when mentioning the app,
for example @VoteApp Blue is my favorite color.
- 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"}}'
