跳到主要内容

Installation

Before diving into the tutorials, you will need to install a few build tools. This guide will show you complete installation process of the minimum tools required to start building your own bots. If you have already installed Node.js version 16 or higher, then go to Install Wechaty.

Install Node.js

Wechaty being a JavaScript based SDK, it requires a JavaScript runtime environment provided by Node.js, and npm which is a package manager for JavaScript. You don't need to download npm separately, as you install Node.js you automatically get npm installed on your system.

Wechaty requires Node.js version higher than 16

You can install the latest version of Node.js on your system by following the links below as per the operating system (OS) you are running:

Node.js installation docs

Installation guide for Node.js on other platforms can be found here.

After the installation is complete, you can check the version of Node.js using:

node -v

You can check your npm version by using:

npm -v

If your Node.js version is not 16 or greater, you can update Node.js and npm to their latest stable version by following instructions in the links below:

Install Wechaty

In order to use Wechaty in your Node.js project, you need to install it inside your project directory. Wechaty is distributed as a npm package, so you can easily install it using the npm CLI tool.

  1. Navigate to your project directory:

    cd <your wechaty dir>
  2. Install wechaty using:

    npm install wechaty

This will add it to the package.json file of your project under dependencies:

{
"name": "wechaty_demo",
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"wechaty": "^0.60.12"
}
}

Install Puppet

For running a Wechaty bot on an instant messaging (IM) systems (such as WeChat, WhatsApp and Gitter) you will need to use Wechaty Puppet.

Wechaty Puppet Providers are npm packages that you can install by using the following command:

npm install wechaty-puppet-NAME

You have to replace the wechaty-puppet-NAME with the puppet you want to use. There are various puppets available, you can choose from here.

Good to go

Now, you have the minimal setup required to build a bot. You can head over to the tutorials.