42wim / matterbridge

bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API (mattermost not required!)
Apache License 2.0
6.43k stars 604 forks source link

WhatsApp Business: failed to join channel (but works with JID from normal WhatsApp account) #1994

Open tuxmartin opened 1 year ago

tuxmartin commented 1 year ago

Describe the bug I'm trying to use WhatsApp Business using WhatsApp integration. I succesfully connect mattebridge using QR code. After that it crashed on:

[0013] FATAL main:         Starting gateway failed: Bridge whatsapp.499xxxxxx failed to join channel: please specify group's JID from the list above instead of the name ''

No channel list is displayed.

But I found "working" solution.

  1. Invite to WhatsApp Business group normal WhatsApp user.
  2. Connect invited normal user WhatsApp to materbridge. It gives you correct list of groups JIDs.
  3. In materbridge.toml use WhatsApp Business account and JID which you found from normal WhatsApp account.

It' strange, but it's working...

To Reproduce

[whatsapp.499xxxxxx]
    Number="+420499xxxxxx"
    SessionFile="/home/matterbridge/whatsapp-session-499xxxxxx.gob"
    RemoteNickFormat="[{PROTOCOL}] @{NICK}: "
    Label="+420"
    QrOnWhiteTerminal=false

[rocketchat.xxx]
    Server="https://rc.example.net/"
    Login="test@example.net"
    Password="xxx"
    PrefixMessagesWithNick=false
    RemoteNickFormat="[{PROTOCOL}] <{NICK}> "

[[gateway]]
name="gateway1"
enable=true

    [[gateway.inout]]
    account = "whatsapp.499xxxxxx"
    channel = "120xxxxxxxxxxxxxxx@g.us"

    [[gateway.inout]]
    account="rocketchat.xxx"
    channel="matterbridge-test"
./matterbridge -conf matterbridge.toml

Expected behavior Get list of channels/JIDs like with normal WhatsApp account.

Screenshots/debug logs

matterbridge@vpn:~$ ./matterbridge -conf matterbridge.toml -debug
[0000]  INFO main:         [setupLogger:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/matterbridge.go:104] Enabling debug logging.
[0000]  INFO main:         [main:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/matterbridge.go:44] Running version 1.26.1-dev 
[0000]  INFO main:         [main:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/matterbridge.go:46] WARNING: THIS IS A DEVELOPMENT VERSION. Things may break.
[0000] DEBUG rocketchat:   [New:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/bridge/rocketchat/rocketchat.go:49] enabling rocketchat
[0000]  INFO router:       [Start:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/gateway/router.go:66] Parsing gateway gateway1
[0000]  INFO router:       [Start:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/gateway/router.go:75] Starting bridge: rocketchat.xxx 
[0000]  INFO rocketchat:   [Connect:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/bridge/rocketchat/rocketchat.go:73] Connecting using login/password (sending and receiving)
[0000] DEBUG rocketchat:   [apiLogin:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/bridge/rocketchat/helpers.go:59] handling apiLogin()
[0000]  INFO rocketchat:   [apiLogin:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/bridge/rocketchat/helpers.go:84] Connection succeeded
[0000]  INFO rocketchat:   [joinChannels:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/bridge/bridge.go:77] rocketchat.xxx: joining matterbridge-test (ID: matterbridge-testrocketchat.xxx)
[0000] DEBUG rocketchat:   [handleRocket:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/bridge/rocketchat/handlers.go:17] Choosing login/password based receiving
[0000]  INFO router:       [Start:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/gateway/router.go:75] Starting bridge: whatsapp.499xxxxxx 
[0000] DEBUG whatsapp:     [Connect:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/bridge/whatsappmulti/whatsapp.go:75] Connecting to WhatsApp..
[0000]  INFO whatsapp:     [Connect:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/bridge/whatsappmulti/whatsapp.go:117] WhatsApp connection successful
[0000]  INFO whatsapp:     [Connect:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/bridge/whatsappmulti/whatsapp.go:135] Getting user avatars..
15:15:59.816 [Client INFO] Successfully authenticated
[0001]  WARN whatsapp:     [Connect:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/bridge/whatsappmulti/whatsapp.go:140] Could not get profile photo of 420499xxxxxx@s.whatsapp.net: failed to get avatar: that user or group does not have a profile picture
[0001]  INFO whatsapp:     [Connect:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/bridge/whatsappmulti/whatsapp.go:150] Finished getting avatars..
[0001]  INFO whatsapp:     [joinChannels:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/bridge/bridge.go:77] whatsapp.499xxxxxx: joining  (ID: whatsapp.499xxxxxx)
[0001]  INFO whatsapp:     [JoinChannel:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/bridge/whatsappmulti/whatsapp.go:200] 120xxx@g.us TestWA
[0001] FATAL main:         [main:/root/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20230129175741-24f6747516a9/matterbridge.go:66] Starting gateway failed: Bridge whatsapp.499xxxxxx failed to join channel: please specify group's JID from the list above instead of the name ''

Environment (please complete the following information):

42wim commented 1 year ago

@yousefmansy1 do you have maybe an idea?

yousefmansy1 commented 1 year ago

@yousefmansy1 do you have maybe an idea?

Unfortunately no, not really familiar with WhatsApp business. It might be bug with how whatsmeow handles WhatsApp business.