• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Wechaty [Matrix] Application Services Bridge

matrix-appservice-wechaty [M] Matrix

Wechat (微信) Matrix Application Service Bridge

Matrix + Wechaty

Image credit: Gnosis

Powered by Wechaty NPM Version NPM Docker TypeScript ES Modules

What is [Matrix]

Matrix is an open network for secure, decentralized communication, which can be used similarly to Pidgin on your phone.

Pidgin tries to have all your friends in one place in Linux, regardless of what IM they use. With Matrix you can have your phone client connected to your private server which can all be highly customized. Matrix does not use the XMPP protocol, it uses a REST API so that it could be easier to extend.

The [Matrix] client Element is a universal secure chat app entirely under your control. It supports desktop (Windows, Mac and Linux) and mobile (Android and iOS)

What is matrix-appservice-wechaty

matrix-appservice-wechaty is a WeChat (微信) Matrix AppService for bridging your WeChat groups to Matrix rooms.

It has been officially listed at [Matrix] Bridge Page for Wechaty.

According to Types of Bridging, the Matrix Wechaty Bot implements a Simple Puppeted Bridge with Portal Rooms because we want to bring all conversations from WeChat to Matrix, and let the Matrix user control his account on Wechat.

Features

  1. Supports connecting to Wechat via the Web/iPad/Hostie/Windows/Mac WeChat protocols, with the power of Wechaty
  2. Maps all Wechat users/room/official accounts to Matrix virtual users

Requirements

  1. A Matrix homeserver that supports application services (e.g. Synapse)
  2. Node.js wit NPM, or Docker

Installation

NPM Version npm (next)

sudo npm install -g matrix-appservice-wechaty

matrix-appservcie-wechaty is all you need.

1 Configure config.yaml

Copy config/config.sample.yaml to config.yaml and update it to match your setup.

  1. domain needs to change to your domain name, which should point to your homeserver.
  2. homeserverUrl needs to change to your homeserver url, with the port number included.
  3. registration needs to change to your registration yaml file name (see next part for how to generate it)

2 Generate wechaty-registration.yaml

After we setup the config.yaml, then we can generate the wechaty-registration.yaml file for registering the appservice to the homeserver:

export APP_SERVICE_ENDPOINT='http://localhost:8788'

matrix-appservice-wechaty \
  --config  config.yaml \
  --url     "$APP_SERVICE_ENDPOINT" \
  --generate-registration

Note: The URL APP_SERVICE_ENDPIOINT is used by the home server to communicate with the appservice, in this example is: http://localhost:8788. If you have other appservices, or other requirements, pick an appropriate hostname and port.

3 Register the App Service

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

app_service_config_files: ["/data/wechaty-registration.yaml"]

4 Restart Home Server (Synapse)

You will then need to restart the synapse server.

For docker users:

export SYNAPSE_CONTAINER_ID=$(docker ps | grep synapse | awk '{print $1}')
docker restart $SYNAPSE_CONTAINER_ID

Or if you are not using docker:

synctl restart

Remember to restart it every time the registration file is updated.

Launch the Wechaty AppService Bridge

Let's start the matrix-appservice-wechaty bridge, with the port specified in wechaty-registration.yaml (8788 in the above example)

export WECHATY_PUPPET=wechaty-puppet-padplus
export WECHATY_PUPPET_PADPLUS_TOKEN=xxxxxxxxxxxxxxxxxxxxx

matrix-appservice-wechaty \
  --config  config.yaml \
  --file    wechaty-registration.yaml

Note: Wechaty is a very powerful framework that supporting Web, iPad, Win32, Mac, iOS protocols of WeChat. Learn more about WeChaty protocols at our Wechaty Puppet Directory, and you can apply for a token for using wechaty-puppet-padplus at our Support Developers Program

The bridge should start working shortly afterwards.

The current path ($(pwd)) should have the wechaty-registration.yaml file and config.yaml file. Additional bridge-related data will be stored here.

Examples

Example wechaty-registration.yaml

id: wechaty
hs_token: 4f2763d5cc6e931967ec89efdde1123772945184b4cbe99e8fa9538122015e92
as_token: c27815bdd699d2eaefb499c83f99ce1a7983a9688811269fbcc17b632b0b250e
namespaces:
  users:
    - exclusive: true
      regex: '@wechaty_.*'
  aliases:
    - exclusive: true
      regex: '#wechaty_.*'
  rooms: []
url: matrix.chatie.io:8788
sender_localpart: wechaty
rate_limited: false
protocols:
  - wechaty

Example config.yaml

domain: chatie.io
homeserverUrl: https://matrix.chatie.io
registration: wechaty-registration.yaml

Example Docker Compose File

dockeri.co

We have published a docker image wechaty/matrix-appservice for your convenience.

You can use docker to run matrix-appservice-wechaty bridge by adding the following configs to your docker-compose.yml

matrix-appservice-wechaty:
  container_name: matrix-appservice-wechaty
  image: wechaty/matrix-appservice
  volumes:
  - ./bridges/matrix-appservice-wechaty:/data
  networks:
  - default
  environment:
  - WECHATY_PUPPET_PADPLUS_TOKEN=puppet_padplus_<token>
  - WECHATY_PUPPET=wechaty-puppet-padplus
  command: ["--config", "/data/config.yaml", "--file", "/data/wechaty-registration.yaml", "--port", "8788"]

Bridge Usage

  1. Direct Message Wechaty Bot (@wechaty:your.domain.ltd)
  2. Send the message !login (three times... wip... )
  3. The wechaty app service bot will then send you a QR Code for scanning on WeChat.

After you have scanned the QR Code and confirmed it on your phone, everything will be setup automatically by the wechaty bot.

Authentication

Logging in

  1. Start a chat with the bridge bot. The bot should say "This room has been registered as your bridge management/status room." if you started the chat correctly.
  2. Run !login
  3. Log in by scanning the QR code. If the code expires before you scan it, the bridge will send an error to notify you.
    1. Open Wechat on your phone.
    2. Tap Menu or Settings and select Scan.
    3. Point your phone at the image sent by the bot to capture the code.
  4. Finally, the bot should inform you of a successful login and the bridge should start creating portal rooms for all your Wechat groups and private chats.

Logging out

Simply run the !logout management command.

Setup Your Matrix Server

By following the guide from @spantaleev, you can set your matrix server up just in dozens of minutes.

TODO

Detail steps to setup the Matrix server from https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/README.md

See Also

Matrix AppService Bridges in TypeScript

Matrix AppService Bridges in JavaScript

Background

This week I had a great talk with YC partner Eric @ericmigi, who is a serial entrepreneur and also a geek with technology. He uses Matrix a lot and almost integrated all the instance messanger to his Matrix.

But, the matrix does not support Wechat yet. So we'd like to introduce a matrix-wechat bridge to implement the Wechat protocol, and fill the gap between Matrix and Wechat.

@ericmigi provide some links that will help us to kick off a starter, hope we could make a workable POC soon, and any contribution will be welcome.

  1. homeserver install in 1 hr
  2. examples of puppet bridges

— Huan, April 2019


@tulir has very rich experiences with building the matrix bridges such as:

  1. A Matrix-Telegram hybrid puppeting/relaybot bridge
  2. A Matrix-WhatsApp puppeting bridge

— Huan, May 2019

Todo/Question List

  • How to get room list from the matrix homeserver from matrix-appservice-bridge ?
  • How to get members from a room from the homeserver matrix-appservice-bridge ?
  • Use Matrix Remote Room for linking WeChat Room with Matrix Room.

History

master

  1. ES Modules support

v0.9 Aug 1, 2021

Finished Display user's nickname and avatar in group #66 and Support image and file messages #86.

  1. Support the display of the nickname and name of the contact.
  2. Support image and file messages.
  3. fix a deprecated function warning.
  4. avoid inviting your own wechaty acount to matrix room.

v0.8 Mar 1, 2020

Finished #13: [TypeScript] Add typing system to matrix-js-sdk and matrix-appservice-bridge.

  1. Code Refactoring
  2. Add !login, !logout command with help message
  3. Tested with iPad API(wechaty-puppet-padplus)

v0.6 (Beta) Feb 25, 2020

  1. added docker-compose.yaml example. (thanks @ericmigi)
  2. Added install documentation

v0.4 (Alpha) July 14, 2019

  1. Support receive/send Wechat message in Matrix. (individuals and rooms)
  2. Tested with Web API(wechaty-puppet-puppeteer) and iPad API(wechaty-puppet-padpro)

Known Issues

  1. The names/avatars of Wechat users/groups are not set right on Matrix.
  2. Only support text message, Image/Audio/Video message is not supported yet. (Will be supported in the future version)
  3. Appservice will create more than one matrix room for a Wechat room when receiving messages from it for the very first time. (It will stop creating new rooms after you accepted the invitation)
  4. Login QR Code should not use the 3rd party API for security considerations. A better way is to upload the QR Code image to matrix server instead.

v0.2 July 6, 2019

  1. Enable your matrix account to start using matrix-appservice-wechaty by talk to the bot @wechaty:your.domain
  2. After you talk to @wechaty, it will send you Wechat Login QR Code. Scan it to login Wechat
  3. All Wechat messages will be bridged to the Matrix system, in the room that you talk to the bot at the very first time.

v0.0.1 May 2019

  1. Auto response the message in a Matrix Room.

Disclaimer

I accept no responsibility if Tencent bans your IP, account or even your details on their system. They have never given official support on custom clients.

— Disclaimer based off: matrix-appservice-discord

Special Thanks

Wechaty community has setup the Matrix service(#94) which the server is sponsored by @ericmigi, who is the founder of Beeper, Partner of Y Combinator. He has also founded Pebble Technology (YC W11), which was acquired by Fitbit in 2016.

Learn more about Beeper from Beeper Brings iMessage to Android - No more green bubbles, LG's exit, Android 12, Oneplus and Oppo

Maintainers

[Matrix] Server Admin:

Copyright & License

  • Code & Docs © 2019-now Huan and Wechaty Contributors https://wechaty.js.org
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons

More Repositories

1

wechaty

Conversational RPA SDK for Chatbot Makers. Join our Discord: https://discord.gg/7q8NBZbQzt
TypeScript
19,950
star
2

python-wechaty

Python Wechaty is a Conversational RPA SDK for Chatbot Makers written in Python
Python
1,568
star
3

getting-started

A Starter Project Template for Wechaty works out-of-the-box
JavaScript
781
star
4

puppet-padlocal

Puppet PadLocal is a Pad Protocol for WeChat
TypeScript
619
star
5

go-wechaty

Go Wechaty is a Conversational SDK for Chatbot Makers Written in Go
Go
480
star
6

puppet-xp

Wechaty Puppet WeChat Windows Protocol
JavaScript
449
star
7

java-wechaty

Java Wechaty is a Conversational SDK for Chatbot Makers Written in Kotlin
Kotlin
409
star
8

puppet-wechat

Wechaty Puppet Provider for WeChat
TypeScript
402
star
9

wechaty-puppet-padplus

DEPRECATED: One puppet based on iPad protocal for Wechaty
TypeScript
315
star
10

wechaty-puppet-padchat

Padchat Puppet for Wechaty
TypeScript
281
star
11

wechaty-puppet-padpro

TypeScript
238
star
12

puppet

Puppet Provider Abstraction for Wechaty
TypeScript
225
star
13

python-wechaty-getting-started

Python Wechaty Starter Project Template that Works Out-of-the-Box
Makefile
180
star
14

docusaurus

Wechaty Official Website for Documentations, Powered by Docusaurus.
MDX
112
star
15

puppet-wechat4u

Wechat4u Puppet for Wechaty
TypeScript
92
star
16

friday

Friday is an Assistant BOT Built on Wechaty for Serving our Community
TypeScript
81
star
17

dotnet-wechaty

.NET Wechaty is a Conversational SDK for Chatbot Makers Written in C#
C#
78
star
18

puppet-service

Wechaty Puppet Provider for providing/consuming the Wechaty Puppet Service
TypeScript
67
star
19

docker-getting-started

Getting Started Template for Docker Users
TypeScript
64
star
20

python-wechaty-template

getting started project template for python-wechaty
Python
56
star
21

php-wechaty

PHP Wechaty is a Conversational SDK for Chatbot Makers Written in PHP https://github.com/wechaty/docker-php-wechaty-getting-started
PHP
55
star
22

java-wechaty-getting-started

Java Wechaty Starter Project Template that Works Out-of-the-Box
Makefile
46
star
23

puppet-mock

Puppet Mocker for Wechaty (& A Puppet Template Starter)
TypeScript
45
star
24

go-wechaty-getting-started

Go Wechaty starter project template that works out-of-the-box
Makefile
44
star
25

bot5

Bot Friday Club - BOT5
TypeScript
39
star
26

python-wechaty-puppet-itchat

Python Wechaty Puppet Powered by Itchat
Python
38
star
27

jekyll

Wechaty Official Website for News, Blogs, Contributor Profiles, Powered by Jekyll.
Java
37
star
28

plugin-contrib

Wechaty Plugin Ecosystem Contrib Package
TypeScript
33
star
29

summer

Summer of Wechaty (SoW) is a program for connecting students with the Wechaty community for coding & tech writing.
32
star
30

chatbot-0-to-1

Chatbot Zero to One
TypeScript
31
star
31

puppet-supports

Wechaty Puppet Services (WPS)
31
star
32

rust-wechaty

Rust Wechaty is a Conversational RPA SDK for Chatbot Makers written in Rust
Rust
24
star
33

puppet-whatsapp

Wechaty Puppet for Whatsapp
TypeScript
24
star
34

puppet-lark

Wechaty Puppet for Lark
TypeScript
23
star
35

webwx-app-tracker

Live Tracking webwxApp Version Change
JavaScript
22
star
36

openapi

Wechaty REST API Server with OpenAPI Specification (aka. Swagger)
JavaScript
22
star
37

wechaty-electron

Wechaty for Desktop
JavaScript
18
star
38

puppet-official-account

Wechaty Puppet for WeChat Official Account
TypeScript
17
star
39

java-wechaty-bak

Java Wechaty is an RPA SDK for WeChat Individual Account
Java
15
star
40

botbuilder-wechaty-adapter

Microsoft Bot Framework v4 Adapter for Wechat Individual Account
TypeScript
15
star
41

puppet-oicq

Wechaty Puppet for QQ based on project takayama-lily/oicq-template
TypeScript
15
star
42

wechaty-weixin-openai

Wechaty plugin for integrate your bot with weixin openai-sdk
TypeScript
13
star
43

python-wechaty-plugin-contrib

Wechaty Plugin Ecosystem Contrib Package
Python
13
star
44

python-wechaty-puppet

Python Puppet Provider Abstraction for Wechaty
Python
12
star
45

dotnet-wechaty-getting-started

.NET Wechaty Starter Project Template that Works Out-of-the-Box
C#
11
star
46

heroku-wechaty-getting-started

Wechaty Starter Project Template with Heroku Deploy Button that Works Out-of-the-Box
TypeScript
10
star
47

puppet-walnut

Wechaty Puppet Walnut - 硬核桃5G消息
TypeScript
9
star
48

mac-wechat-app-tracker

macOS WeChat.app header files version history (automatic updated)
Objective-C
9
star
49

python-wechaty-puppet-service

Python Puppet Service Client for Wechaty
Python
8
star
50

wechaty-puppet-dingtalk

TypeScript
8
star
51

php-wechaty-getting-started

PHP Wechaty Starter Project Template that Works Out-of-the-Box
Makefile
8
star
52

scala-wechaty

Scala Wechaty is a Conversational SDK for Chatbot Makers Written in Scala
Scala
8
star
53

python-wechaty-puppet-padplus

Python Hostie Puppet for Wechaty
Python
7
star
54

easy-matrix-wechaty

A simple and fast temporary deployment solution for [matrix-appservice-wechaty](https://github.com/wechaty/matrix-appservice-wechat) with matrix. (Easy to be a multi bridge server for other matrix bridges.)
Shell
7
star
55

wishlist

Puppets, Bots, and other Tooling Requested by Community Members
6
star
56

im-aggregation

Aggregate WeCom, WeChat, and WhatsApp together.
TypeScript
6
star
57

chat

Friday BOT empowered by GPT-4 with maximum token length 32K, grounded with Wechaty SDK knowledge
5
star
58

wechaty-ui

Web UI for polyglot-wechaty based on the plugin system.
Vue
5
star
59

cqrs

An event-driven architecture wrapper for Wechaty that applies the CQS principle by using separate Query and Command messages to retrieve and modify the bot state, respectively.
TypeScript
5
star
60

vorpal-contrib

Wechaty Vorpal Chat CLI (Command Line Interface) Commands
TypeScript
4
star
61

PMC

Project Management Committees
Shell
4
star
62

wechaty-puppet-macOS

Wechaty Puppet Provider: macOS,make your macOS as a service provider for your self.
Objective-C
4
star
63

ha

High Available (HA) Wechaty is a Load Balance for providing High Availability for Wechaty Chatbot by spreading requests across multiple WeChat individual accounts.
TypeScript
4
star
64

redux

Wechaty Redux Plugin, Reducer Bundle, and Ducks Proposal Implementation.
TypeScript
4
star
65

wechaty-got-kicked-out

this is a wechaty plugin to monitor whether your bot is kicked out of group chat.
TypeScript
4
star
66

plugin-qnamaker

QnAMaker.ai Plugin for Wechaty
TypeScript
4
star
67

bot5-assistant

BOT Friday Club Meeting Assistant BOT
TypeScript
3
star
68

plugin-chatopera

🐸 Chatopera Plugin for Wechaty
TypeScript
3
star
69

sidecar-demos

Sidecar Demos & Examples
JavaScript
3
star
70

cli

Terminal Client for Wechaty
TypeScript
3
star
71

bot5-rasa-nlu

Rasa NLU for Bot5
Dockerfile
3
star
72

vorpal

CLI for Chatbot - Extensible Commands for ChatOps, Powered by Vorpal.
TypeScript
3
star
73

docker-php-wechaty-getting-started

Getting Started Template for Docker Users
Shell
2
star
74

puppet-discord

Discord Puppet for Wechaty
TypeScript
2
star
75

ducks-contrib

Wechaty Ducks Contrib
JavaScript
2
star
76

token

Wechaty Token-Based Authentication Manager
TypeScript
2
star
77

ngNext-hackthon-2020-Conversational-AI

2
star
78

plugin-freshdesk

Wechaty Freshdesk Plugin helps Freshdesk unifies conversations from WeChat, and helps you resolve issues across channels effortlessly!
TypeScript
2
star
79

chat-drive

Chat Drive is a conversational storage solution that allows you to save files from the WeChat room, and search & access them anytime by talking to our chatbot.
TypeScript
2
star
80

chatbot-1-to-2

the source code of chatbot-1-to-2
JavaScript
1
star
81

qrcode

Online QRCode Image Generator
HTML
1
star
82

php-grpc

PHP Stubs for Chatie GRPC (DO NOT EDIT: Code generated by grpc_php_plugin)
PHP
1
star
83

js.org

Wechaty Official Website for News, Blogs, Contributor Profiles, and Documentations.
1
star
84

rust-wechaty-getting-started

Rust Wechaty Starter Project Template that Works Out-of-the-Box
Makefile
1
star
85

OSSRH-56843

https://issues.sonatype.org/browse/OSSRH-56843
1
star
86

go-grpc

Go Stubs for Chatie GRPC (DO NOT EDIT: Code generated by protoc-gen-go)
1
star
87

python-wechaty-puppet-official-account

Wechaty Puppet for WeChat Official Account
Python
1
star
88

actor

Wechaty Actor Model, Powered by XState, Mailbox, and CQRS
JavaScript
1
star
89

plugin-intercom

Wechaty Intercom Plugin helps you build better customer relationships through WeChat across the customer journey.
TypeScript
1
star
90

wechaty-puppet-sidecar

A Universal Puppet Powered by Sidecar
TypeScript
1
star
91

puppet-gitter

Gitter.im Puppet for Wechaty
TypeScript
1
star
92

OSSRH-56865

https://issues.sonatype.org/browse/OSSRH-56865
1
star