User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
matrix:whatsapp [2025/03/11 07:21] – created willymatrix:whatsapp [2025/03/12 07:20] (current) – [Bridge setup] willy
Line 1: Line 1:
-===== Installing the Whatsapp Bridge =====+===== Matrix Whatsapp Bridge =====
  
 +[[https://www.whatsapp.com/|Whatsapp]] needs no presentation. It's the de-facto standard for private and group chats. Nobody can live without it, and it seems to be permanently installed on every device we purchase. Also, lots of malware and spyware is known to be installed trough whatsapp itself.
  
 +Unfortunately, you cannot get rid of whatsapp fully, since the official client for mobile (Android and IOS) is the only way to keep a working whatsapp profile. 
 +
 +Using the Matrix bridge, you can remove all your whatsapp client permissions, including disable notifications. You still need to keep it installed somewhere on the phone with your main phone number, and open it once every week or so to prevent all your secondary profiles to be disabled.  
 +
 +You could install Whatsapp on an Android Virtual Emulator and fake your phone numnber on it, but it's strongly discouraged because it can get your whatsapp acocunt permanently banned. You have been warned.
 +
 +Whatsapp can be easily and fully bridged with Matrix using the Mautrix-Whatsapp bridge [[https://docs.mau.fi/bridges/go/whatsapp/index.html|here]].
 +
 +===== Installation =====
 +
 +I asusme you are installing the bridge directly together with the Matrix server, as user //conduwuit//.
 +
 +Create a subfolder to install the bridge:
 <code bash> <code bash>
 su - conduwuit su - conduwuit
Line 8: Line 22:
 wget -O mautrix-whatsapp.zip 'https://mau.dev/mautrix/whatsapp/-/jobs/artifacts/main/download?job=build%20amd64'  wget -O mautrix-whatsapp.zip 'https://mau.dev/mautrix/whatsapp/-/jobs/artifacts/main/download?job=build%20amd64' 
 unzip mautrix-whatsapp.zip unzip mautrix-whatsapp.zip
 +chmod +x mautrix-whatsapp
 </code> </code>
  
-Generate config and edit:+ 
 +===== Bridge setup ===== 
 + 
 +Let the bridge generate the basic configuration file, and move it to the /data/conduwuit folder:
 <code bash> <code bash>
 ./mautrix-whatsapp -e ./mautrix-whatsapp -e
Line 16: Line 34:
 </code> </code>
  
-edit it...+Now edit it. You should take a good look at it, the following are only hints and pointers to what you aboslutely need to change:
 <code> <code>
 network: network:
-    displayname_template: "{{or .FullName .BusinessName .PushName .Phone}} (WA)" # This is very important to have usernames instead of phone numbers!+    # This is very important to have usernames instead of phone numbers! 
 +    displayname_template: "{{or .FullName .BusinessName .PushName .Phone}} (WA)" 
          
 database: database:
Line 28: Line 47:
     address: https://chat.mydomain.com     address: https://chat.mydomain.com
     domain: chat.mydomain.com     domain: chat.mydomain.com
-    + 
 +appservice: 
 +    hostname: 127.0.0.1 
 +  
 permissions: # this is probably not needed, but anyway... permissions: # this is probably not needed, but anyway...
   "*": "relaybot"                      # non-local users can only see messages   "*": "relaybot"                      # non-local users can only see messages
Line 41: Line 63:
     allow: true     allow: true
  
-double puppeting +double_puppet: 
 +    # Servers to always allow double puppeting from. 
 +    # This is only for other servers and should NOT contain the server the bridge is on. 
 +    servers: 
 +        anotherserver.example.org: https://matrix.anotherserver.example.org 
 +    # Whether to allow client API URL discovery for other servers. When using this option, 
 +    # users on other servers can use double puppeting even if their server URLs aren'
 +    # explicitly added to the servers map above. 
 +    allow_discovery: false 
 +    # Shared secrets for automatic double puppeting. 
 +    # See https://docs.mau.fi/bridges/general/double-puppeting.html for instructions. 
 +    secrets: 
 +        chat.mydomain.com: as_token:<< here the double-puppet token >> 
 +         
 +logging: 
 +      filename: /var/log/conduwuit/mautrix-whatsapp.log
 </code> </code>
  
 Note that backfill is disabled by default, you need to enable it to see older messages. Also note that messages **cannot** be backfilled for already created rooms, so don't forget to enable backfill before the first start! Note that backfill is disabled by default, you need to enable it to see older messages. Also note that messages **cannot** be backfilled for already created rooms, so don't forget to enable backfill before the first start!
  
-Generate the appservice files:+Since my server will have just a few users, i decided to use an SQLite database.  
 + 
 + 
 +===== Bridge Registration ===== 
 + 
 +At this point you need to register the bridge with the Matrix server. 
 + 
 +First of all, generate the //registration.yaml// file:
 <code bash> <code bash>
 ./mautrix-whatsapp -c  /data/conduwuit/mautrix-whatsapp-config.yaml -g ./mautrix-whatsapp -c  /data/conduwuit/mautrix-whatsapp-config.yaml -g
 </code> </code>
  
-This step will create a **registration.yaml** file that you need to perform the registration of the bridge as an appservice in Conduwuit. Conduwuit is different from Synapse (the most common Matrix server) because the appservice must be registered from the admin chat with the following command: +Then perform the actual appservice registration, see [[matrix:appservices|here]].
-<code> +
-!admin appservices register << shift+enter >> +
-```  << shift+enter >> +
-id: whatsapp +
-... copy the content of the appservice.yaml .. ] +
-``` << enter >> +
-</code>+
  
-When you see **<< shift enter >>** you need to press those two keys in order to create a new line in the same command. The three **```** (backthicks) are the markdown token to create a code block. 
- 
-The chat should reply with a message like: 
-<code> 
-Appservice registered with ID: whatsapp 
-</code> 
  
-More details on registering the appservice can be found [[https://docs.mau.fi/bridges/general/registering-appservices.html|here]].+===== Usage =====
  
 The **whatsappbot** user should have been created automatically. The **whatsappbot** user should have been created automatically.
Line 79: Line 109:
 If all is well, your bridge should be up and running now. If all is well, your bridge should be up and running now.
  
 +
 +===== Login =====
 To login into whatsapp you need to: To login into whatsapp you need to:
   * Start a chat with whatsappbot:chat.mydomain.com   * Start a chat with whatsappbot:chat.mydomain.com
Line 87: Line 119:
  
 **Note:** if your usernames do not get popupated, you should do a //search username// in the whatsappbot chat. **Note:** if your usernames do not get popupated, you should do a //search username// in the whatsappbot chat.
 +
 +
 +===== Autostart =====
 +
 +Since i use OpenRC, simply drop the following script to /etc/init.d:
 +<file - /etc/init.d/conduwuit-whatsapp>
 +#!/sbin/openrc-run
 +# Copyright 2025 Gentoo Authors
 +# Distributed under the terms of the GNU General Public License v2
 +
 +name="conduwuit whatsapp bridge"
 +description="Conduwuit whatsapp Matrix Bridge"
 +pidfile="/run/conduwuit-whatsapp.pid"
 +command_background=true
 +command="/data/daemons/conduwuit/mautrix-whatsapp/mautrix-whatsapp"
 +command_args="/data/conduwuit/mautrix-whatsapp-config.yaml"
 +command_user="conduwuit:conduwuit"
 +output_log="/var/log/conduwuit/conduwuit-whatsapp.log"
 +output_err="/var/log/conduwuit/conduwuit-whatsapp.log"
 +
 +start_pre() {
 +        cd /data/daemons/conduwuit/mautrix-whatsapp
 +}
 +
 +depend() {
 +        need net
 +}
 +</file>
 +
 +Make it executable and add to the proper runlevel:
 +<code bash>
 +chmod +x /etc/init.d/conduwuit-whatsapp
 +rc-update add conduwuit-whatsapp default
 +</code>
 +
 +
  

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information