Sending Messages to Hangout Chat Room from a Server using Webhook URL
This article describes how to send a Text message from a Ubuntu Server to a Google Hangout Chat (Google’s paid team chat service, provided as part of Google Workspace) using a Webhook URL by executing a Python Script over the command line.
Let’s start with Prerequisites
- Gmail Account from a Google workspace(Previously G Suite Team).
Example: user@examplepvtltd.com
2. Ubuntu Server. (You may follow this on any Linux based server using appropriate package managers)
Step 1 — Create a Google Hangout Group and Webhook URL
- Open Google Hangout Chat Application
- Create a Chat Room to get the Alert


2. Create Webhook URL


Step 2 — Set up the Ubuntu Server to Run a Python Script
Now we are done with the Google Hangout Chat App side configuration. Let’s Install the Python, pip(Package manager for python), and other required packages.
# Update the packages list and install the prerequisites:
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
# Install Python
sudo apt install python3.8
python — version
# Install pip3
sudo apt update
sudo apt install python3-pip
pip3 — version
# Install Required Modules to run the python script
pip install httplib2
Step 3 — Create the Python Script
Now our server is ready to execute the script. Let’s add the Webhook URL and Text Message we need to send to our Google Hangout Chat Room.
Get the Python script from here
Edit the script and change URL and message:
vim send_message.py
url = 'Copy and Pase Webhook URL here'
message = {
'text' : 'This is a test message from your server'}
Step 4 — Execute the Python Script
# Make the file executable
sudo chmod +x send_message.py
# Execute the script
python3 send_message.py
👏👏👏 Check your Google Hangout chat Room:
