This code sample creates a simple Google Chat app that listens for messages via Cloud Pub/Sub.
For more information on how to build with Pub/Sub, please read the guide.
Before you can run the sample, do the following:
- Follow the directions for setting up a topic and subscription as described in Build a Google Chat app behind a firewall with Pub/Sub.
- Run the sample, substituting your subscription id and service account JSON file from step 1.
PROJECT_ID=your-project-id SUBSCRIPTION_ID=your-subscription-id GOOGLE_APPLICATION_CREDENTIALS=your-service-account.json mvn compile exec:java \ -Dexec.mainClass=Main
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.