Google Apps Script bot

Complete the following steps to create a simple Hangouts Chat bot. The bot can be directly messaged, and responds by echoing your messages.


To run this quickstart, you need:

  • A Google account.

Step 1: Create the script

  1. Open the Google Apps Script Editor using the Hangouts Chat Bot template.

  2. Click File > Save, name the project "Quickstart bot", and click OK.

You need the Deployment ID for this Apps Script project, so that you can use it in the next step. To get the Deployment ID, do the following:

  1. Click Publish > Deploy from manifest.
  2. In the Deployments dialog box next to Latest Version (HEAD), click Get ID.
  3. In the Deployment ID dialog box, copy the value listed for the Deployment ID.
  4. Click Close and Close to dismiss the dialog boxes.

Step 2: Publish the bot

  1. In the Script Editor with the 'Quickstart bot' project open, click Resources > Cloud Platform project.
  2. In the Cloud Platform project dialog box, click the URL for the project associated with the script.
  3. In the Google Cloud Console, enable the Hangouts Chat API by doing the following:

    1. In the navigation, click APIs & Services > Dashboard.
    2. In the Dashboard, click Enable APIs and Services.
    3. Search for "Hangouts Chat API" and enable the API.

    4. Once the API is enabled, click the Configuration tab. In the Configuration pane, do the following:

      • In the Bot name field, enter 'Quickstart bot'.
      • In the Avatar URL field, enter ''.
      • In the Description field, enter 'Quickstart bot'.
      • Under Functionality, select Bot works in direct messages.
      • Under Connection settings, select Apps Script project and paste the Deployment ID into the field.
      • Under Permissions, select Specific people and groups in your domain, and enter your own email.
    5. When you've finished configuring your bot, click Save Changes.

For more information about how to publish a bot, see Publishing bots.

Step 3: Run the sample

To run the sample, do the following:

  1. Create a new direct message with the bot by clicking Find people, rooms, bots > Message a Bot.
  2. On the Add bot page, under Find a bot, type 'Quickstart Bot'.
  3. Select the Quickstart Bot.
  4. In the new direct message with the bot, type 'hello'.

The bot thanks you for adding it and echoes your message.

Further reading

Send feedback about...

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