Skip to main content

Running locally

You can setup your own server for running locally. Just follow the steps below:

  1. Install build tools
  2. Clone the Wechaty Getting Started repository
  3. Install dependencies
  4. Run the bot
import { Wechaty } from 'wechaty'
async function main () {
const bot = new Wechaty()
bot
.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}`))
await bot.start()
}
main()
.catch(console.error)

Requirements#

  1. Node.js v12+
  2. Wechaty Puppet Service TOKEN (if you want to use RPA protocols other than Web)

1. Install build tools#

Install Node.js (>=12)#

You will need Node.js for running the bot. If you do not have Node.js installed (or have a version below 12), then you need to install the latest version of Node.js by following the links below:

Node.js installation docs

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

Install make#

You will need make for running the Makefile, use the command below to install:

sudo apt install build-essential

2. Clone repository#

You can clone the Wechaty Getting Started repository by following the below command, and navigate to the directory:

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

3. Install dependencies#

For installing the required npm dependencies run the following:

# npm install
make install

4. Run the bot#

First, you have to export/set the environment variables, and then you can run the bot:

export WECHATY_LOG=verbose
export WECHATY_PUPPET=wechaty-puppet-wechat
make bot
# the above is equals to the below command:
# npm start
# or, npx ts-node examples/ding-dong-bot.ts

You can install npx by using this command:

npm install -g npx

There are various Wechaty puppets available, you can know more about them here.

You can see the following result after running:

demo

This demo will show all message on the bot.

Showcase#

Wechaty Developers' Home

Scan the following QR Code in WeChat with secret code wechaty, join our Wechaty Developers' Home. This group is only for developers.

Friday BOT

Learn more about our open-sourced Friday BOT from our showcases

Contact us#

You can join our Gitter network if you aren’t already a member.

Last updated on by Souvik Biswas