OpenAI ChatGPT connects to WeChat wechatbot. Tutorial on building a WeChat chatbot!

How to connect ChatGPT to WeChat and use OpenAI API and itchat to build a WeChat chatbot? ChatGPT has recently become popular on the Internet with its super dialogue and information integration capabilities. ChatGPT can rewrite papers, write novels and tell stories, program and write codes, and can also draw pictures and generate pictures intelligently. It is almost omnipotent. How can ChatGPT be connected to WeChat and turn WeChat into an intelligent WeChat chatbot?

Connect OpenAI ChatGPT to WeChat and you can get any questions answered by @ing you in the group!

how use Build with Itchat? ChatGPT has recently become popular on the Internet with its powerful conversation and information integration capabilities. ChatGPT can rewrite papers, write novels and tell stories, program and write codes, draw pictures, and intelligently generate pictures. It is almost omnipotent like a god. How can ChatGPT be connected to WeChat and turn WeChat into an intelligent WeChat?, you can give unexpected replies in chats with friends, which is really amazing!

OpenAI ChatGPT connects to WeChat wechatbot. Tutorial on building a WeChat chatbot!

ChatGPT is an open source chatbot framework that usesThe GPT-3 language model can realize natural language processing, question-answering, and dialogue generation. In layman's terms, it is an AI chatbot. Here's how to connect the AI chatbot, ChatGPT, to WeChat

OpenAI ChatGPT connects to WeChat wechatbot. Tutorial on building a WeChat chatbot!

ChatGPT is connected to WeChat

The first step is to register ChatGPT. There are many tutorials for registering ChatGPT online, so I won’t go into detail here. You can refer to the latest ChatGPT registration tutorial in 2023:

ChatGPT registration Open Ai ChatGPT free code receiving platform, 😍 personally tested and effective! A real and available code receiving platform

Preparations before connecting ChatGPT to WeChat

  • OpenAI account (sign up and get $18 trial credit)
  • OpenAI API Key
  • A WeChat account (it is recommended to use a small account for testing)
  • A Linux server (Amazon, Microsoft or Google Cloud servers are fine.)

Get the OpenAI API Key

After creating an OpenAI account, log in to OpenAI and create an API keys. This key is very important. It is the key required for the program to access the OpenAI interface.

Log in to your OpenAI account:https://platform.openai.com/login/

This login address is different from the login address of ChatGPT. Here is the login address for OpenAI.

OpenAI ChatGPT is connected to WeChat. Tutorial on building a WeChat chatbot using OpenAI API! -1

After entering the correct email and password, you will be taken to the OpenAI user interface.

OpenAI ChatGPT is connected to WeChat. Tutorial on building a WeChat chatbot using OpenAI API! -1

After logging in, click the avatar in the upper right corner, then click View API keys to enter the API keys creation page.

OpenAI ChatGPT is connected to WeChat. Tutorial on building a WeChat chatbot using OpenAI API! -1If you are not good at English, you can use the built-in translation tool of Google Chrome to translate it into Chinese.

OpenAI ChatGPT is connected to WeChat. Tutorial on building a WeChat chatbot using OpenAI API! -1

Click to create a new key. After the API keys key is created, click the copy button to save the key. Create a new document on the desktop and paste it in. You will need the openai API keys key later.

OpenAI ChatGPT is connected to WeChat. Tutorial on building a WeChat chatbot using OpenAI API! -1

Install and deploy Wechatbot

based onopenwechatThe wechatbot project.

Project open source address:https://github.com/djun/wechatbot

Wechatbot requires a golang environment. Different operating systems require different go environments.

Download golang software

Download the go installation package:https://studygolang.com/dl

After downloading the appropriate installation package for your system, follow Installation Instructions If you choose to build from source, please refer to Installing from source.Check Release History Learn more about Go release notes.

The latest installation package of go language, you can choose windows, linux, mac according to different systems.

OpenAI ChatGPT is connected to WeChat. Tutorial on building a WeChat chat robot using wechatbot! -1

GO source code
go1.20.1.src.tar.gz (25MB)
Apple macOS
macOS 10.13 or later, Intel 64-bit processor
go1.20.1.darwin-arm64.pkg (92MB)
Linux
Linux 2.6.23 or later, Intel 64-bit processor
go1.20.1.linux-amd64.tar.gz (95MB)
Microsoft Windows
Windows 7 or later, Intel 64-bit processor
go1.20.1.windows-amd64.msi (95MB)

Linux environment configuration

The test system is Centos8. Install the go language environment first.

dnf install git
dnf install golang

OpenAI ChatGPT connects to WeChat wechatbot. Tutorial on building a WeChat chatbot!

# Get the wechat project git clone https://github.com/ZYallers/chatgpt_wechat_robot.git # Enter the project directory cd chatgpt_wechat_robot # Copy the configuration file cp config.dev.json config.json

Edit the config.json configuration file.

vi config.json

OpenAI ChatGPT connects to WeChat wechatbot. Tutorial on building a WeChat chatbot!

Configuration file description

{ "api_key": "your api key", "auto_pass": true, "session_timeout": 60, "max_tokens": 1024, "model": "text-davinci-003", "temperature": 1, "reply_prefix": "Reply from robot:", "session_clear_token": "Clear session" } api_key: openai api_key auto_pass: whether to automatically add through friends session_timeout: session timeout, default 60 seconds, unit seconds, all information sent to the robot during the session time will be used as context. max_tokens: number of characters in GPT response, maximum 2048, default value 512. max_tokens will affect the response speed of the interface, the larger the characters, the slower the response. model: GPT selected model, default text-davinci-003, specific options refer to the official website training ground temperature: GPT heat, 0 to 1, default 0.9. The larger the number, the more creative it is, but it deviates further from the training facts. The lower the number, the closer it is to the training facts. reply_prefix: private chat reply prefix session_clear_token: session clear token, defaultNext question

Replace your api key in the config.json file with the OpenAI keys you applied for previously.

Focus on the api_key field and fill in the API Keys we obtained previously on the OpenAI website

After modifying the configuration file, start the service.

go run main.go

After successful startup, visit the following URL and scan the QR code to log in to WeChat.

OpenAI ChatGPT connects to WeChat wechatbot. Tutorial on building a WeChat chatbot!

Register a WeChat secondary account to log in to avoid the main account being blocked! No one can tell why the account was blocked, so it is better to be cautious.

Use your own WeChat account to scan the code. This WeChat account requires personal real-name authentication.

Note: The WeChat account you use to scan the QR code to log in is a chat robot!

Installing the process daemon

dnf install screen

After installation, open a new window and restart the chatbot

screen -S chatgpt

After successful startup, press Ctrl + A + D to suspend the background service. If you want to view the running status, enter the following command to view it.

screen -R chatgpt

This way the bot will continue running in the background even if you disconnect from your VPS.

At this point, the WeChat chatbot has been built. ChatGPT is still being optimized and iterated. I believe there will be more surprises in the future. Let us wait and see!

Solution to the error after terminating the go program and rerunning it

[WARNING]2023/02/10 20:00:03 logger.go:33: login error: write storage.json: bad file descriptor

Solution: Delete the storage.json file in the chatGpt_wechat directory and log in again.

References:View WeChat official documentation

 

1/5 - (1 vote)

Leave a Reply

Your email address will not be published. Required fields are marked *