/hangouts-chat-rss-bot

A simple Google Apps Script bot that fetches news from an RSS feed and posts them to a Hangouts Chat room.

Primary LanguageJavaScriptMIT LicenseMIT

Hangouts Chat RSS bot - Standard RSS feed support

A simple Google Apps Script that fetches news from an RSS feed and posts them to a Hangouts Chat room using webhooks.

This sample uses the Google Cloud Platform blog as an example.

Create a Hangouts Chat webhook

  1. (Optional) Create a new room for testing

  2. Select the "Configure webhooks" menu:

    Configure webhooks
  3. Create the new webhook by providing a name and an optional URL to a public image:

    New webhook
  4. Once created, you will see your new webhook with it's URL. This is the URL we will use to post new messages to the room:

    View webhooks

Setup the Google Apps Script

  1. Create a new Google Apps Script project

  2. Copy the content of /Code.gs to a file in your Google Apps Script project

  3. Update the WEBHOOK_URL variable with the URL of your webhook (see Create a Hangouts Chat webhook)

    Update script

Manually run the script

Note that this step is required as you need to manually run the script a first time to go through the authorization process

You can easily test the script by manually running the fetchNews() function from the Google Apps Script editor:

Run

At the first execution, you will be prompted to authorize the script to send external requests.

Auth Required

Click on "Review Permissions" and authorize the script by clicking on the "Allow" button:

Authorize

Once the script finished its execution, you should see new topics posted in your Hangouts Chat room:

Post

\o/ yay!

Schedule updates

At each run, the script will parse the RSS feed and automatically post new articles that were published since it's last execution.

You can easily schedule the execution of the script at regular intervals using Time-driven triggers.

To set a new trigger, click on the Triggers icon on your Google Apps Script project:

Triggers

Then schedule a new Time-driven trigger to automatically execute the "fetchNews" function at a regular interval (e.g. every 10 minutes):

Schedule trigger

Share your room!

Share your room to everyone in your company and react together to new exciting news!

React