Wechaty is a RPA (Robotic Process Automation) SDK for Chatbot Makers which can help you create a bot in 6 lines of JavaScript, Python, Go, and Java, with cross-platform support including Linux, Windows, MacOS, and Docker.
:octocat: https://github.com/Wechaty/wechaty
:beetle: https://github.com/Wechaty/wechaty/issues
:book: https://github.com/Wechaty/wechaty/wiki
:whale: https://hub.docker.com/r/wechaty/wechaty
"Wechaty is a great solution, I believe there would be much more users recognize it." link
— @Gcaufy, Tencent Engineer, Author of WePY"太好用,好用的想哭"
— @xinbenlv, Google Engineer, Founder of HaoShiYou.org"最好的微信开发库" link
— @Jarvis, Baidu Engineer"Wechaty让运营人员更多的时间思考如何进行活动策划、留存用户,商业变现" link
— @lijiarui, Founder & CEO of Juzi.BOT."If you know js ... try Wechaty, it's easy to use."
— @Urinx Uri Lee, Author of WeixinBot(Python)"Wechaty is a good project, I hope it can continue! Therefore, I became a contributors in open collective."
— @Simple
See more at Wiki:Voice Of Developer
Wechaty is used in many ChatBot projects by thousands of developers. If you want to talk with other developers, just scan the following QR Code in WeChat with secret code wechaty, join our Wechaty Developers' Home.
Scan now, because other Wechaty developers want to talk with you too! (secret code: wechaty)
You are also welcome to join our Gitter channel at https://gitter.im/wechaty/wechaty with your GitHub account!
Wechaty already held lots of talk and got a lot of blogs in the past 4 years, here is all of the wechaty resources:
const { Wechaty } = require('wechaty') // import { Wechaty } from 'wechaty'
Wechaty.instance() // Global Instance
.on('scan', (qrcode, status) => console.log(`Scan QR Code to login: ${status}\nhttps://wechaty.js.org/qrcode/${encodeURIComponent(qrcode)}`))
.on('login', user => console.log(`User ${user} logged in`))
.on('message', message => console.log(`Message: ${message}`))
.start()
Notice: Wechaty requires Node.js version >= 12
This bot can log all messages to the console after login by scan.
You can find Wechaty Official Example at examples/ding-dong-bot.ts, and more from our Example Directory.
sudo apt-get install build-essential && sudo snap install shellcheckWe have a Wechaty starter repository for beginners with the simplest setting. It will be just work out-of-the-box after you clone & npm install & npm start.
If you are new to Wechaty and want to try it the first time, we'd like to strong recommend you starting from this repository, and using it as your starter template for your project.
Otherwise, please saved the above The World's Shortest ChatBot Code: 6 lines of JavaScript example to a file named bot.js before you can use either NPM or Docker to run it.
npm init
npm install wechaty
# create your first bot.js file, you can copy/paste from the above "The World's Shortest ChatBot Code: 6 lines of JavaScript"
# then:
node bot.js
Wechaty Docker supports both JavaScript and TypeScript. To use TypeScript just write in TypeScript and save with extension name
.ts, no need to compile because we usets-nodeto run it.
2.1. Run JavaScript
# for JavaScript
docker run -ti --rm --volume="$(pwd)":/bot wechaty/wechaty bot.js
2.2. Run TypeScript
# for TypeScript
docker run -ti --rm --volume="$(pwd)":/bot wechaty/wechaty bot.ts
Learn more about Wechaty Docker at Wiki:Docker.
Wechaty is very powerful that it can run over different protocols. You can specify the protocol by set the environment variable WECHATY_PUPPET to different puppet provider.
If you cannot use Web protocol, you can apply other protocal following the instruction here: https://github.com/wechaty/wechaty/wiki/Support-Developers We provide free token to support developers build a valuable WeChat chatbot.
Currently we support the following puppet providers :
| Protocol | Puppet Provider | Environment Variable |
|---|---|---|
| Web | PuppetPuppeteer | export WECHATY_PUPPET=wechaty-puppet-puppeteer |
| Windows | PuppetWxwork | export WECHATY_PUPPET=wechaty-puppet-service |
| Mock | PuppetMock | export WECHATY_PUPPET=wechaty-puppet-mock |
| Web | PuppetWechat4u | export WECHATY_PUPPET=wechaty-puppet-wechat4u |
| iPad | PuppetRock | export WECHATY_PUPPET=wechaty-puppet-service |
| iPad | PuppetPadLocal | export WECHATY_PUPPET=wechaty-puppet-service |
| Windows | PuppetDonut | export WECHATY_PUPPET=wechaty-puppet-service |
| iPad | ~~PuppetPadpro~~ DEPRECATED | export WECHATY_PUPPET=wechaty-puppet-padpro |
| iPad | ~~PuppetPadchat~~ DEPRECATED | export WECHATY_PUPPET=wechaty-puppet-padchat |
| iPad | ~~PuppetPadplus~~ DEPRECATED | export WECHATY_PUPPET=wechaty-puppet-padplus |
| Mac | ~~PuppetMacpro~~ DEPRECATED | export WECHATY_PUPPET=wechaty-puppet-macpro |
Learn more about Wechaty Puppet from the Puppet Wiki:
Read the Full Documentation at Wechaty Official API Reference
WechatyMain bot class.
A Bot is a Wechaty instance that control a specific wechaty-puppet.
new Wechaty(options?: WechatyOptions)options.name?: string the name of this bot(optional)options.puppet?: string select which puppet provider we want to use. must be one of the:options.puppetOptions?: PuppetOptions options for the puppet provider.| Wechaty | API | Description |
|---|---|---|
| event | login |
emit after bot login full successful |
| event | logout |
emit after the bot log out |
| event | friendship |
emit when someone sends bot a friend request |
| event | message |
emit when there's a new message |
| event | room-join |
emit when anyone join any room |
| event | room-topic |
emit when someone change room topic |
| event | room-leave |
emit when anyone leave the room |
| event | room-invite |
emit when there is a room invitation |
| event | scan |
emit when the bot needs to show you a QR Code for scanning |
| method | start(): Promise<void> |
start the bot |
| method | stop(): Promise<void> |
stop the bot |
| method | logonoff(): boolean |
bot login status |
| method | logout(): Promise<void> |
logout the bot |
| method | userSelf(): ContactSelf |
get the login-ed bot contact |
| method | say(text: string): Promise<void> |
let bot say text to itself |
ContactAll wechat contacts(friends/non-friends) will be encapsulated as a Contact.
| Contact | API | Description |
|---|---|---|
| static | find(query: string): Promise<null \| Contact> |
find contact by name or alias, if the result more than one, return the first one. |
| static | findAll(query: string): Promise<Contact[]> |
find contact by name or alias |
| static | load(query: string): Contact |
get contact by id |
| property | id: readonly string |
get contact id |
| method | sync(): Promise<void> |
force reload data for contact , sync data from lowlevel API again |
| method | say(text: string): Promise<void \| Message> |
send text, Contact, or file to contact, return the message which the bot sent (only `pupp |
$ claude mcp add wechaty \
-- python -m otcore.mcp_server <graph>