Send Hangouts message from command line on Debian

Finally found a possibility to send a message from commandline via Google Hangouts, thanks to the hangups messaging client.


Hangups requires Python 3.3, 3.4, or 3.5 and can be installed via pip3:

apt-get install python3-pip
pip3 install hangups

First start

Create an Google Account for your “Chat Bot” and follow the User Guide / Logging In.

hangups --token-path /root/.cache/hangups/refresh_token.txt

Open, log in with your “Chat Bot” account and invite your contacts.

Example send message application

NOTE: The following example works for user “root”. If another user should be used, the send message application must be saved as /usr/local/bin/ and references to /root changed to /home/USERNAME.

Download “send message” example application:

wget -O /usr/local/sbin/

Edit /usr/local/sbin/ and change the following part, basically use stdin as MESSAGE, change REFRESH_TOKEN_PATH and CONVERSATION_ID:

"""Example of using hangups to send a chat message to a conversation."""

import sys

import asyncio

import hangups

# ID of the conversation to send the message to. Conversation IDs can be found
# in the hangups debug log by searching for "conversation_id".

# Plain-text content of the message to send.
MESSAGE = ''.join(sys.stdin)

# Path where OAuth refresh token is saved, allowing hangups to remember your
# credentials.
REFRESH_TOKEN_PATH = '/root/.cache/hangups/refresh_token.txt'


grep -A 1 UgyoEJW1M5TLSnPWY494AaABAQ /root/.cache/hangups/log/hangups.log

Sending Hangouts message

echo "hello world" | python3 /usr/local/sbin/
--- Logging error ---
Traceback (most recent call last):
--- Logging error ---
Traceback (most recent call last):

# supress error messages
echo "hello world" | python3 /usr/local/sbin/ 2>/dev/null

Tested on Debian Jessie.