Skip to content
Public template

About

A Starter Project Template for Wechaty works out-of-the-box

Topics

Resources

Stars

853 stars

Watchers

18 watching

Forks

Repository files navigation

Wechaty Getting Started Powered by Wechaty

Node.js CI Node.js v26 TypeScript ES Modules

About Wechaty

Wechaty is a Conversational RPA(Robotic Process Automation) SDK(Software Development Kit) for Chatbot Makers. It's well designed with an easy to use API. It supports all operating systems including Linux, OSX, Win32, Docker, and lots of IMs(Instant Messaging services) including WeChat, WeCom, Whatsapp, Lark, Gitter, etc.

As a developer, you can use Wechaty to easily build your bot, effectively manage message sending and receiving, room creation and sending out invitations, contact friends, and delightfully add artificial intelligence between users and your bot.

About Wechaty Getting Started Project

If you are a total beginner to Wechaty, this project is the best starting point for you. You can run it on Google Cloud Shell or on a local setup on your machine as described in the sections below.

If you encounter difficulties or have any questions, you are welcome to ask for help in our Discord Community at https://discord.gg/7q8NBZbQzt.

This repository tracks Wechaty 2. It needs Node.js 26 or newer and TypeScript 7.

Features of Wechaty Getting Started project

  1. It runs on Linux x64 and arm64 (glibc 2.38 or newer), macOS on Apple Silicon, and Windows x64.
  2. The starter bot uses Wechaty Puppet Neo.
  3. It replies with a dong message when it receives a ding message.

Wechaty Getting Started video tutorial

Above is a short run-through of the ding-dong bot.

Running Wechaty Getting Started Project on a cloud based IDE

Google Cloud Shell is an online development and operations environment accessible anywhere with your browser. You can run this project on Google Cloud Shell by clicking the button below.

Open in Cloud Shell

Generated via open-in-cloud-shell

After opening the Google Cloud Shell editor, there should be an open tutorial in the right panel which you can follow to learn more about Wechaty.

Learn more about running this project on Google Cloud Shell from our blog: Google Cloud Shell Tutorials for Wechaty, @huan, Feb 20, 2021

Running Wechaty Getting Started project on your local machine

Prerequisites

For you to run this project on your local machine, you need Node.js v26 or newer and npm 10 or newer. Run node -v and npm -v to check. A current Node.js 26 release looks like v26.13.1.

Install Node.js from the links below when it is missing or older than 26:

Node.js for other platforms can be found at https://nodejs.org/en/download/package-manager/

Puppet Neo publishes prebuilt native addons for:

Platform Node.js
Linux x64 and arm64 glibc 2.38 or newer
macOS Apple Silicon
Windows x64 x64 Node.js, including Windows on ARM under x64 emulation

Run node -p process.arch on Windows on ARM. It needs to print x64.

Step 1: Clone this Repository

You need to clone this repository to your local machine and then switch to wechaty-getting-started directory by running the commands below.

git clone https://github.com/wechaty/getting-started.git
cd getting-started

Step 2: Install Dependencies

You need to install dependencies by running the command below.

npm install

npm install selects the newest Wechaty 2 release, including a later alpha, a beta, or a stable 2.x.

Step 3: Run the Bot

npm start

The same command works on Linux, macOS, and Windows. Node.js runs examples/ding-dong-bot.ts directly. The bot is built with WechatyBuilder and new PuppetNeo().

A QR code is printed in the terminal. Scan it with WeChat. Neo keeps the login in memory, so every start prints a new QR code.

After the bot logs in, send ding from another WeChat account, in a direct chat or in a group that includes this account. The bot replies dong.

You are all set!

Step 4: Troubleshooting

If you run into problems while following the above steps, check the items below. You are also welcome to ask questions in our gitter chatroom.

  1. node -v is v26 or newer, and npm -v is 10 or newer.
  2. On Linux, ldd --version reports glibc 2.38 or newer.
  3. node -p process.arch is x64 on Linux x64 and Windows, or arm64 on Linux arm64 and macOS Apple Silicon.

Wechaty Puppet Neo

The ding-dong bot in this repository uses wechaty-puppet-neo through WechatyBuilder.

Provider NPM Login
Puppet Neo wechaty-puppet-neo In memory. A new QR code on every start.
import { WechatyBuilder } from 'wechaty'
import { PuppetNeo } from 'wechaty-puppet-neo'

const bot = WechatyBuilder.build({
  name: 'ding-dong-bot',
  puppet: new PuppetNeo(),
})

Learn more about installing Wechaty on windows from this blog post.

Advanced tutorials

1. Wechaty Tutorial

Above is a 10 minute video tutorial. It is using version 0.14 or older versions of Wechaty therefore it is also outdated. It is a good way to start if you are new to Wechaty.

2. More Examples

Note: Before you attempt more examples, make sure you have tried out the wechaty getting started project in this repository.

The files under examples/ other than the two starter bots are v1-era samples. The root package does not install them.

API REFERENCE

  1. Official API Docs: https://wechaty.js.org/docs/api

MORE RESOURCES

1. Docker Wechaty Getting Started

Docker

https://github.com/wechaty/docker-wechaty-getting-started

2. Heroku Wechaty Getting Started

Heroku

https://github.com/wechaty/heroku-wechaty-getting-started

3. Wechaty Home

https://wechaty.github.io

FAQ

1. How do I log in

npm start prints a QR code. Scan it with WeChat and confirm the login on the phone. Neo stores that login in memory, so stopping the process and starting it again prints a new QR code.

2. What is a Puppet in Wechaty

The term Puppet in Wechaty is an abstract class for implementing protocol plugins. The plugins are the components that help Wechaty control a chat service, which is why they are called puppets.

This repository uses PuppetNeo. Learn more from the documentation at Wechaty Puppet.

Wechaty Getting Started in Multiple Languages

Wechaty in Python Wechaty in Go Wechaty in Java Wechaty in Scala Wechaty in PHP Wechaty in .NET(C#)

History

main (Wechaty 2)

Node.js 26, TypeScript 7, and wechaty-puppet-neo. The starter bot uses WechatyBuilder and new PuppetNeo().

main v1.18 (Mar 14, 2022)

Add CQRS Wechaty examples.

v1.11 (Oct 30, 2021)

Branch: v1.11: release v1.11 of Wechaty.

  1. v0.13: Enable ESM (ES Module) support (chatie/tsconfig#16)

v0.8 (Feb 20, 2021)

Open in Cloud Shell

Using Google Cloud Shell for a quick setup!

v0.0.1 (Jan 12, 2017)

Init version

Contributors

contributor contributor contributor contributor contributor contributor contributor contributor

Maintainers

@wechaty/contributors

Copyright & License

  • Code & Docs © 2018-now Huan and Wechaty Contributors
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons

About

A Starter Project Template for Wechaty works out-of-the-box

Topics

Resources

Stars

853 stars

Watchers

18 watching

Forks

Used by

Contributors

Languages