This code sample creates a simple Google Chat app that listens for messages via Cloud Pub/Sub.
Before you can run the sample, do the following:
- Follow the directions for setting up a topic and subscription as described in Using Cloud Pub/Sub as an endpoint for your app.
- Start a virtual environment
python -m venv env source env/bin/activate
- Install libraries using
pip
.pip install -r requirements.txt -U
- Run the sample, substituing your subscription id and service account JSON file from step 1.
SUBSCRIPTION_ID=your-subscription-id GOOGLE_APPLICATION_CREDENTIALS=your-service-account.json python app.py
Either add and @mention the app in a room or in a direct mention to engage with the app.
When added to a room or messaged, the app will respond with a simple reply.