Project Icon

getting-started

Wechaty入门 构建跨平台智能对话机器人

Wechaty Getting Started项目是一个跨平台智能对话机器人开发框架,支持WeChat、WeCom、Whatsapp等多种即时通讯平台。它提供云端IDE和本地环境两种部署方式,支持多种编程语言,让开发者能轻松实现消息收发、群聊创建、联系人管理等功能。该项目简单易用,是快速构建智能对话系统的理想起点,有助于实现智能人机交互。

Wechaty Getting Started Powered by Wechaty

Node.js CI Node.js v16 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 a Cloud IDE in a couple of steps 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.

Notice: the current active version of Wechaty is v1.x which is not compatible with most of the v0.x modules.

Features of Wechaty Getting Started project

  1. It works out of the box on Linux, Mac or Windows.
  2. Supports all puppets like Web, Pad, Windows, and Mac.
  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 deploying the ding-dong-bot using WeChat, WhatsApp, and WeCom.

Running Wechaty Getting Started Project on a cloud based IDE

The fastest way to getting started with Wechaty is to use a Cloud based IDE for running the Wechaty Getting Started Project. You can either use Gitpod or Google Cloud Shell.

If you are a total beginner, then we recommed Gitpod.

Using Gitpod ❤️ Wechaty

Gitpod is an online and open source platform for automated and ready-to-code development environments. You can click the button below to access a complete setup of Wechaty Getting Started ding-dong BOT project on gitpod. If you have never used gitpod before, you will be required to login using your gitHub account.

[![GitPod Ready-to-Code][gitpod_img]][gitpod_link]

You can learn more about Gitpod ❤️ Wechaty from our blog: Getting Started Without Leaving Your Browser: Wechaty ❤️ Gitpod, @huan, Feb 06, 2021

Using Google Cloud Shell

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][shell_img]][shell_link]

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 to:

  1. Have Node.js v16+ installed on your machine. You can run the command node -v on the terminal to check whether you have Node.js installed. If you have it, you should be able to see the version printed on the terminal like v16.13.0. Your version might be different from v16.13.0. If it is not installed or your version is below 16, You need to install the latest version by following the links below:

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

  2. Have Wechaty Puppet Service TOKEN if you want to use RPA protocols other than Web

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

Step 3: Run the Bot

You can use export to set environment variables in Linux, and use set in Windows. If you run into errors while running this command, check the troubleshooting tips in step 4.

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

You are all set!

Step 4: Troubleshooting

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

  1. You might also need windows-build-tool if you are using windows:

    npm install windows-build-tools
    

Working with Different Puppets

In our getting started example, the ding-dong BOT uses wechaty-puppet-wechat4u when WECHATY_PUPPET is not set, which is just for newcomer's convenience.

By default, Wechaty will use the Puppet Service for logging in your bot. You can use other Puppet Provider like Whatsapp Web protocol( wechaty-puppet-whatsapp).

If you want to use a Wechaty Puppet Provider for a different protocol, then you need to specify a puppet service provider name (the same as its NPM name) by setting the WECHATY_PUPPET environment variable.

Thanks to the great contributions from our community, there are many Wechaty Puppets which can be used by Wechaty. They have helped us use protocols like Web, Pad, Mac, and Windows.

Wechaty Puppets

ProtocolNPM
Puppet Servicewechaty-puppet-service
Whatsapp Webwechaty-puppet-whatsapp
WeChat Webwechaty-puppet-wechat
WeChat Padwechaty-puppet-padlocal

Visit our website to learn more about Wechaty Puppet Service Providers

For example, if you want to use the padlocal puppet, you should set WECHATY_PUPPET=wechaty-puppet-padlocal before you run npm start. You also need a TOKEN for wechaty-puppet-padlocal which you need to set to the WECHATY_PUPPET_PADLOCAL_TOKEN environment variable. You can apply for the PadLocal TOKEN from here. The code snippets below illustrate what has been described above on Linux/ MacOS and on Windows.

On Linux / macOS

export WECHATY_PUPPET=wechaty-puppet-padlocal
export WECHATY_PUPPET_PADLOCAL_TOKEN='puppet_padlocal_your-token-here'
npm start

On Windows

set WECHATY_PUPPET=wechaty-puppet-padlocal
set WECHATY_PUPPET_PADLOCAL_TOKEN='puppet_padlocal_your-token-here'
npm start

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.

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. I can not login with my Wechat account

WeChat account registered after 2017 will not be able to login via Web API. Learn more about it at https://github.com/Chatie/wechaty/issues/872

Solution: You can use Wechaty support protocols other than Web API, such as pad. Learn more at https://github.com/Chatie/wechaty/issues/1296

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 to control Wechat and that's the reason why we call it puppet.

The plugins are named PuppetXXX, for example PuppetWeChat is using the google puppeteer to control the WeChat Web API via a chrome browser, PuppetPadchat uses the WebSocket protocol to connect with a Protocol Server for controlling the iPad Wechat program. For more details you can go to Puppet in wiki.

Learn more about Wechaty Puppet from our 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 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][shell_img]][shell_link]

Using Google Cloud Shell for a quick setup!

v0.6 (Feb 11, 2021)

[![GitPod Ready-to-Code][gitpod_img]][gitpod_link]

Using Gitpod for a quick setup!

v0.0.1 (Jan 12, 2017)

Init version

项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

吐司

探索Tensor.Art平台的独特AI模型,免费访问各种图像生成与AI训练工具,从Stable Diffusion等基础模型开始,轻松实现创新图像生成。体验前沿的AI技术,推动个人和企业的创新发展。

Project Cover

SubCat字幕猫

SubCat字幕猫APP是一款创新的视频播放器,它将改变您观看视频的方式!SubCat结合了先进的人工智能技术,为您提供即时视频字幕翻译,无论是本地视频还是网络流媒体,让您轻松享受各种语言的内容。

Project Cover

美间AI

美间AI创意设计平台,利用前沿AI技术,为设计师和营销人员提供一站式设计解决方案。从智能海报到3D效果图,再到文案生成,美间让创意设计更简单、更高效。

Project Cover

稿定AI

稿定设计 是一个多功能的在线设计和创意平台,提供广泛的设计工具和资源,以满足不同用户的需求。从专业的图形设计师到普通用户,无论是进行图片处理、智能抠图、H5页面制作还是视频剪辑,稿定设计都能提供简单、高效的解决方案。该平台以其用户友好的界面和强大的功能集合,帮助用户轻松实现创意设计。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号