Sample Code

The Hangouts Chat repo on GitHub includes several samples that demonstrate how to build bots. In addition, you can use the Hangouts Chat codelab to learn more about how to build a bot using Apps Script.

Sample HTTP and Pub/Sub bots

In the Hangouts Chat repo on GitHub, you can find Java and Python versions of the following code samples:

  • Basic bot: This bot receives event notices and messages from Hangouts Chat and responds synchronously with simple text responses. The sample demonstrates how to create an HTTP endpoint bot using Google App Engine.
  • Basic async bot: This bot receives event notices and messages from Hangouts Chat and responds asynchronously with simple text responses. The responses appear in the same thread that raised the original event or message. This sample is an HTTP endpoint bot built upon Google App Engine.
  • Pub/Sub bot: This bot uses Google Cloud Pub/Sub to receive messages from Hangouts Chat. The bot responds back to Hangouts Chat asynchronously.
  • Card bot: This bot receives event notices and messages from Hangouts Chat and responds synchronously with a card-formatted response. The sample is an HTTP endpoint bot built upon Google App Engine.

Codelabs

You can follow the Hangouts Chat with Apps Script codelab to learn more about the Hangouts Chat bot platform as well as how to build a bot using Apps Script.

You can find the code for each step in the codelab in the Hangouts Chat codelab repo on GitHub.

Send feedback about...

Hangouts Chat API
Hangouts Chat API
Need help? Visit our support page.