Backend Development 12 min read

Integrating DeepSeek AI with a WeChat Public Account: A Step‑by‑Step Backend Tutorial

This tutorial walks beginners through obtaining a DeepSeek API key, setting up an Alibaba Cloud ECS instance, configuring the server and WeChat public platform, installing required Python dependencies, editing configuration files, and finally running the chatbot so the public account can interact with the DeepSeek large‑language model.

Architect's Guide
Architect's Guide
Architect's Guide
Integrating DeepSeek AI with a WeChat Public Account: A Step‑by‑Step Backend Tutorial

1. Basic Principles & Risks

The guide uses a GitHub open‑source project to bridge DeepSeek API and the WeChat public‑account API; messages received by the account are forwarded to a cloud server, processed by the AI model, and the replies are sent back. Users are warned about potential mis‑configuration risks for both WeChat and the cloud server.

2. Obtaining a DeepSeek API Key

Visit https://platform.deepseek.com/ , register, create an API key on the dashboard and copy it for later use.

3. Getting WeChat Public‑Platform Credentials

Log in to the WeChat public platform, become a developer, and copy the AppID , AppSecret , generate an AESKey , and note the Token .

4. Creating a Cloud Server (Alibaba Cloud ECS)

Register on Alibaba Cloud , apply for the free ECS trial (Hong Kong region, 2 CPU + 2 GiB, Ubuntu 22.04), open port 80 in the security group, and obtain the public IP address.

5. Project Code Configuration

5.1 Clone the Project

git clone https://github.com/zhayujie/chatgpt-on-wechat.git

5.2 Install Dependencies

pip3 install -r ./chatgpt-on-wechat/requirements.txt
pip3 install -r ./chatgpt-on-wechat/requirements-optional.txt

5.3 Edit the Configuration File

Create config.json with the collected credentials, e.g.:

{
  "channel_type": "wechatmp",
  "model": "deepseek-chat",
  "open_ai_api_key": "YOUR_DEEPSEEK_API_KEY",
  "open_ai_api_base": "https://api.deepseek.com/v1",
  "wechatmp_app_id": "YOUR_APPID",
  "wechatmp_app_secret": "YOUR_APPSECRET",
  "wechatmp_aes_key": "YOUR_AESKEY",
  "wechatmp_token": "YOUR_TOKEN",
  "wechatmp_port": 80,
  "conversation_max_tokens": 3000,
  "temperature": 0.8,
  "subscribe_msg": "Thanks for following! The public account is now connected to DeepSeek."
}

5.4 Save the File

Use vi config.json , press I to edit, paste the JSON, then Esc :wq to save and quit.

5.5 Run the Project

sudo python3 app.py

For unattended operation, use:

(cd chatgpt-on-wechat && nohup python3 app.py &) ; tail -f ./chatgpt-on-wechat/nohup.out

6. WeChat Public‑Platform Configuration

In the WeChat console set the server URL to http://YOUR_SERVER_IP/wx , and fill the Token and AESKey with the same values from config.json . Choose “compatible mode”, submit, enable the configuration and verify success.

7. Post‑Deployment Tips

Periodically restart the ECS instance and re‑run the start command.

Customize the configuration (model, prompts, etc.) after understanding each field.

Monitor Alibaba Cloud free‑trial quota and DeepSeek API usage to avoid unexpected charges.

Following these steps will connect your WeChat public account to the DeepSeek large‑language model, enabling AI‑driven conversations.

backendPythonAPIDeepSeektutorialcloudWeChat
Architect's Guide
Written by

Architect's Guide

Dedicated to sharing programmer-architect skills—Java backend, system, microservice, and distributed architectures—to help you become a senior architect.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.