[mautrix-whatsapp] Bridge between matrix and whatsapp

My YunoHost server

Hardware: Internet Cube with VPN lime 2
**YunoHost ** 3.6.4.3 (stable)
I have access to my server : Through SSH | through the webadmin
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : yes
If yes, please explain: root is on a SATA HDD and I installed a hotspot through usb-ethernet dongle.

Description of my project

mautrix-whatsapp an application service for matrix-synapse based on a postgres DB and installed thanks to golang-go. I managed to have the matrix-whatsapp puppeting bridge working on my server mainly by following the wiki:

I also spent some time finding the right configuration to make it work alongside synapse_ynh.

I started packaging it here:

Issues

In conf/app.src I added:
SOURCE_URL=https://github.com/tulir/mautrix-whatsapp.git
SOURCE_FORMAT=git
I’m wondering how to get the source files cloned from the app git repo into /opt/yunohost/$app

Should I copy the source files to my git repo and adapt the configuration files there?

Is there a chance that I get the package to a high level of integration while keeping the dependency to golang?

Alternatives

I’m wondering if it would be harder/better/cleaner to package one of the following apps instead:

1 Like

Wooho thank you @gauthier67 for starting this package ! I’m really interested in this :slight_smile:

My 2 cents…
I think Matterbridge is really ugly compare to puppetting bridge (which impersonate users) like mautrix-whatsapp ^^
I also kept an eye on this Ansible project for a long time, I requested to split bridges and synapse so I could use it with Yunohost. But I don’t think Ansible fit with Yunohost philosophy (but don’t take my word, I’m no maintainer). Though we could benefit from a lot of bridges and the hardwork done upstream. It could be awesome.

1 Like

Hi @nouts your request was fullfiled https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/174
Did you clarify if it makes sense to package an app with ansible ?

I really don’t know if it make sense. IMHO I don’t think it fit the philosophy of Yunohost.
We should ask some maintainers of Yunohost what they think about it, like @Josue who packaged synapse.
Nevertheless it’s an open project, if you feel about it you should do it. :slight_smile:

I just mentionned the Ansible project for the sake of it, as now my request was accepted I will use it because I’ll get more job done in a minimum effort.

Well, thanks to @tituspijean, it works ! Just have to test it on my test server to actually connect it to a whatsapp account.
The PR is here: https://github.com/YunoHost-Apps/mautrix-whatsapp_ynh
Only the install script has been tested a bit. So do not deploy on production server!

3 Likes

So, the install and remove is now working in master branch. Waiting for approval of the PR for integration in apps list.
The next step is to find an easy way to have a whatsapp instance running outside of a phone. Technically, the packager of the app give a tutorial to set up an android VM. But this is a tedious process.

I would dream of a Yunohost app to set up a lightweight android VM for whatsapp, so that people do not have to install it on their phone anymore. The idea behind is to facilitate/enable transition from the GAFAM environments to a FLOSS environment. So to say, force inter-operability.

For those interested in the question of packaging matrix bridges for synapse_ynh, I opened a topic #mautrix_yunohost:matrix:fdn.fr

3 Likes

Hi, first of all, thank you Gauthier for the whatsapp bridge which works well !

I wonder if there is a solution to build easily a Telegram bridge also ? Because none of the necessary packages are available in Debian 9 (Python > 3.6 or Docker).

And to be honest, i’m totally noob and I’ve tried to install Synapse and the bridges on a VPS from scratch and with ansible, but I’ve never succeeded…

Thanks for the feedback. What is your experience with the bridge? Are you using it on a daily basis? Are you using the relaybot too?

My experience is that the dependencies are not an issue. This is basically one of the main purpose of yunohost packaging. Some helpers are available to install them even if these are not in stretch repo. Could be also that python 3.6 is available in debian 10. Yunohost 4 (based on debian 10) is coming soon. Beta testing is already available.

So if you would start packaging telegram, better do it for yunohost 4 directly. Having a look at https://github.com/tulir/mautrix-telegram/wiki/Bridge-setup I would say that the python-based installation looks very similar to the synapse installation

1 Like

I’ve installed it 3 days ago and since then it has been working perfectly well.

Are you using the relaybot too?

What is exactly the relaybot ?

So if you would start packaging telegram, better do it for yunohost 4 directly.

Regarding the telegram bot, maybe I’ll give it another try but everytime I’ve tried to build it, I had an error somewhere and didn’t know exactly what I was doing. I’ve litteraly spent hours trying to figure it out, but I’m definitively too noob for this job :upside_down_face:

Great to find this package, thank you!

I have been trying to get mautrix_whatsapp running for the last two weeks, without success, before I got pointed to this package by another mautrix_whatsapp user.

Unfortunately, I can’t get the package to install.

I’m on Yunohost 4 / Buster. Should I take the buster branch or the main branch? I have tried those two, and testing as well.

Would the defaults work, or can I mess up enough there to have the install fail? I don’t understand the question ‘choose the matrix users authorized to bridge with the bot (default: admin)’. Is admin a matrix user? And the question before that, main account: should that be the YNH-user (‘username’) or the matrix user (’@username:domain.tld’)?

These are the install logs,
main branch: https://paste.yunohost.org/raw/fezifijede
(warning: go is not found)
buster branch: https://paste.yunohost.org/raw/upepuwopuh
(warning: a git repo is not found, build.sh is not found)

I know that the Go-version provided with Buster is to old for the stand alone / non-YNH version of mautrix_whatsapp. Does the package take care of that? Should I install a newer Go by hand?

You should use the buster branch. Note that the upgrade, backup and restore scripts are not working. You need to mkdir -p /etc/matrix-synapse/app-service before installing, see this PR https://github.com/YunoHost-Apps/synapse_ynh/pull/213#issuecomment-692348806 . I cannot reproduce your error about not finding ./build.sh but it looks like it goes into mautrix_whatsapp_src instead of mautrix_whatsapp
Correct go version is handled by the script. What is your architecture? I only tested on x64.

To understand the questions please have a look at the manifest file. It is better explained in the web admin.

Feel free to do a PR to improve the package!

1 Like

I can’t believe it, it works! Wohoo!

That is, here is no error in /var/log/mautrix_whatsapp/log.log:


Info: [############+.......] > Configuring system user... [00h01m,16s]
Info: [#############++.....] > Configuring a systemd service... [00h00m,01s]
Warning: cp: cannot stat '/etc/matrix-synapse/conf.d/app_service.yaml': No such file or directory
Warning: rm: cannot remove '/tmp/app_service_backup.yaml': No such file or directory
Info: [###############+....] > Configuring log rotation... [00h00m,06s]
Info: [################++..] > Starting a systemd service... [00h00m,00s]
Info: [####################] > Installation of mautrix_whatsapp completed [00h00m,02s]
Success! Installation completed
root@sanyi:~# tail -f /var/log/mautrix_whatsapp/log.log 
[Sep 15, 2020 09:59:29] [DEBUG] Relaybot is enabled, but not logged in
[Sep 15, 2020 09:59:29] [DEBUG] Checking connection to homeserver
[Sep 15, 2020 09:59:30] [ERROR] Failed to connect to homeserver: failed to ensure registered: msg=Failed to POST JSON to /_matrix/client/r0/register:  code=502 wrapped=. Retrying in 10 seconds...
[Sep 15, 2020 09:59:40] [DEBUG] Starting application service HTTP server
[Sep 15, 2020 09:59:40] [DEBUG] Starting event processor
[Sep 15, 2020 09:59:40] [INFO] Bridge started!
[Sep 15, 2020 09:59:40] [Matrix/INFO] Listening on 0.0.0.0:8449
[Sep 15, 2020 09:59:40] [DEBUG] Updating bot profile
[Sep 15, 2020 09:59:40] [DEBUG] Starting users
[Sep 15, 2020 09:59:40] [DEBUG] Starting custom puppets

I’m so happy :smiley:

2 Likes

Hey, I used your signal bridge to try and build one for telegram.
Building seems to work as well as running the bridge; but the bridge won’t join the room i invite it to.

if anyone else could have a look at it, would be appreciated.

Demain mercredi 24/02 à 19H30 sur mumble.april.org terrasse Est. on va causer interopérabilité des alternatives à whatsapp avec des CHATONS qui font du XMPP et du matrix.

Have you tried restarting your server? My mautrix_instagram_ynh did not work until after I had restarted my server for some reason.

Also, can you dump the logs for your app?

Nevermind, the problem was that I mistyped the botname in the configuration; hard to debug if everything works as it should…

@navanchauhan @benneti I don’t know how much experience you have with yunohost app packaging. How about pushing your repositories on YunoHost-Apps · GitHub ?

The Yunohost bridge app is now referenced on the official documentation Bridge setup - mautrix-bridges

@gauthier67, I am currently testing a couple of apps. Once I am satisfied they work correctly, I will request for their integration :smiley:

@gauthier67 I have no experience at all, but I am not opposed to integrating it. On the downside I plan to switch my homeserver to nixos when I switch the hardware, so I would probably not maintain the app for too long (but for as long as I use it myself I feel comfortable doing it).