Awesome Open Source
Awesome Open Source


This is a Matrix bridge for Google Hangouts. It logs in as (aka "puppets") both your matrix user and your hangouts user to establish the bridge. For more information, see:

To interact with the google hangouts servers, this bridge uses a python hangouts client library called hangups:


For hangups, and our own python, python3 (Python 3.5+ for async) is required:

sudo apt install python3 python3-dev (Or similar for your package manager)

Make sure your python3 is version 3.5+ by running python3 --version

Install hangups system-wide:

sudo pip3 install hangups


Clone this repo or download a release of the puppet

cd into the directory

run npm install


Copy config.sample.json to config.json and update it to match your setup.

You should really only have to edit the homeserverUrl and domain values. If you are running the puppet on the same server as your homeserver, then you should probably set the homeserverUrl value to be

Login to hangouts to save your authentication token.

Run the following

mkdir -p ~/.cache/hangups
python3 --login-and-save-token

This saves an authentication token into the default hangups token path (~/.cache/hangups/ as of this writing).

Troubleshooting Login

Refresh token not found

If you get an error like this

Traceback (most recent call last):
  File "/home/keyvan/code/matrix-puppet-hangouts/env/lib/python3.6/site-packages/hangups/", line 158, in get_auth
    raise GoogleAuthError("Refresh token not found")
hangups.auth.GoogleAuthError: Refresh token not found

Then try logging in through a real browser first (lynx should work) to get past the SMS verification.

If you are still having this issue, make sure you turn off "Login with my phone" and "2-step verification". You may be able to turn these back on AFTER you've successfully logged in, but this is unconfirmed.

You can control these settings here:

Authorization code cookie not found

If you get an error that says something along the lines of:

Login failed (Authorization code cookie not found)

You may get your refresh token manually using hangups itself:

hangups --manual

(follow the instructions on screen in order to get the refresh token)

While this will take you into a hangups TUI once everything is done, you can exit it with Control+E.

Register the app service

Note: your-bridge-server is simply the IP address or hostname that your puppet will be running on, as it utilizes its own HTTP server for functionality. If you are running Synapse and the puppet on the same system, feel free to use localhost or

Generate an hangouts-registration.yaml file with node index.js -r -u "http://your-bridge-server:8090"

This command above will ask you to sign in as a user. You should sign in as a user that is an administrator, otherwise you might experience problems.

Note: The 'registration' setting in the config.json needs to set to the path of this file. By default, it already is.

Copy this hangouts-registration.yaml file to your home server (or to the homeserver's configuration directory if the puppet and homeserver are the same system), then edit it, setting its url to point to your bridge server. e.g. url: ''.

Edit your homeserver.yaml file and update the app_service_config_files with the path to the hangouts-registration.yaml file.

Launch the bridge with npm start.

Restart your HS.

A handy way to control your puppet is through systemd. Here is a systemd service, that can be called hangouts-puppet and placed at /etc/systemd/system.

Description=Hangouts Matrix Puppet

ExecStart=/usr/bin/npm start


This service will auto-restart when the puppet fails. If you want that to not be the case, remove the lines:


Discussion, Help and Support

Join us in the Matrix Puppet Bridge room

Using this puppet to bridge two group chats

This is a simple hack in order for this puppet to be usable to bridge two group chats, one on Matrix and one on Hangouts.

  1. Have a Google account that will be just for this puppet and create your hangups refresh token with this account.
  2. Run register_new_matrix_user -c homeserver.yaml http://localhost:8008 on your Synapse homeserver. Make sure that this user is an administrator.
  3. Now run node index.js -r -u "http://your-bridge-server:8090", but use the admin user you created before this in the registration.
  4. Follow other steps as detailed to get the puppet running.
  5. When the puppet starts successfully with npm start, invite the puppet's Google account to the group chat on Hangouts.
  6. By default, the sender's name is not shown, which makes it very difficult to bridge two group chats, because you wouldn't know who is who on the Matrix side in Hangouts. However, if you replace this block of code in index.js
sendMessageAsPuppetToThirdPartyRoomWithId(id, text) {
    return this.thirdPartyClient.send(id, text);
sendImageMessageAsPuppetToThirdPartyRoomWithId(id, data) {
  return this.thirdPartyClient.sendImage(id, data);


sendMessageAsPuppetToThirdPartyRoomWithId(id, text, event) {
    return this.thirdPartyClient.send(id, "**" + event.sender.split(":")[0].substring(1) + "**\n" + text);
sendImageMessageAsPuppetToThirdPartyRoomWithId(id, data, event) {
  this.sendMessageAsPuppetToThirdPartyRoomWithId(id, "**" + event.sender.split(':')[0].substring(1) + "**", event);
  return this.thirdPartyClient.sendImage(id, data);

you should be able to see the sender's name from Matrix in the Hangouts chat.

All this does is the puppet adds a line before every message stating the sender in bold. While this only shows the localpart (username without homeserver), if you replace event.sender.split(":")[0].substring(1) with just event.sender, you will be able to see the username with the homeserver at the end, like

At the end, you should be able to just log in to Riot or your favorite client as that admin user that you created, and invite your real account to the "bridged" room.


  • Be able to start a brand new hangouts conversation fully from within a matrix client by choosing participants from your google contacts list. Currently, to start a new conversation this way, you'll have to start the conversation with an official hangouts client where your full contact list is available and once you send a message a bridged room will automatically be created for you. After this, you can carry on the rest of the conversation using your matrix client. Naturally, any incoming message will also automatically create a bridged room for you, so this limitation only applies when creating brand new rooms yourself. See this comment by tfreedman for a proposed solution to this problem - and if you have any better ideas, please let us know!
  • Add a bot to each hangouts bridge room and use the bot's presence to indicate whether the bridge is running. This is an easy way to check on the status of the bridge.
  • Read receipt support.
  • Typing notification support.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
python (50,919
google (389
matrix (132
vector (110
riot (16

Find Open Source By Browsing 7,000 Topics Across 59 Categories