Integrating Coze API with WeChat Group Chatbots

Account Risk Warning

Automating WeChat messages violates platform policies and carries a high risk of account suspension. Always operate using a secondary WeChat account to isolate potential bans from your primary profile.

System Architecture

The domestic Coze platform now exposes its API, allowing developers to bypass the web interface and integrate AI capabilities directly into external applications. The integration strategy utilizes an OpenAI-format adapter to translate requests for the Coze API, bridging it with a standard WeChat bot framework to enable group chat interactions.

Prerequisites

  • A lightweight cloud server equipped with a management panel (such as BaoTa).
  • WeChat Bot Framework: chatgpt-on-wechat
  • Coze API Adapter: coze2openai

If your server encounters network restrictions pulling from GitHub, clone the adapter repository to a local machine and upload the archive to the server manually.

Adapter Configuration

Access the adapter project directory on your server. Two primary modifications are required: setting your specific Coze Bot ID and redirecting the endpoint to the domestic Coze API.

Update the request handler to point to the regional base URL and adjust the payload structure:

const apiResponse = await fetch("https://api.coze.cn/open_api/v2/chat", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Connection": "keep-alive",
    "Host": "api.coze.cn",
    "Accept": "*/*",
    Authorization: `Bearer ${accessToken.split(" ")[1]}`,
  },
  body: JSON.stringify(payloadData),
});

Node Environment Setup

Verify that Node.js is installed on the host system. Through your server management panel, register the adapter as a new Node application and start the process. It will bind to port 3000 by default, awaiting incoming OpenAI-compatible requests.

WeChat Bot Deployment

Within your management panel, create a new application using a Docker Compose template. Insert the following configuration, ensuring you replace placeholder values with your actual Coze API token and server IP address:

version: "2.0"
services:
  wechat-bot-service:
    image: zhayujie/chatgpt-on-wechat
    container_name: wechat_coze_bot
    security_opt:
      - seccomp:unconfined
    environment:
      OPEN_AI_API_KEY: "YOUR_COZE_API_TOKEN"
      MODEL: "coze-bot"
      OPEN_AI_API_BASE: "http://YOUR_SERVER_IP:3000/v1"
      PROXY: ""
      SINGLE_CHAT_PREFIX: '["bot", "@bot"]'
      SINGLE_CHAT_REPLY_PREFIX: '"[bot] "'
      GROUP_CHAT_PREFIX: '["@bot"]'
      GROUP_NAME_WHITE_LIST: '["Tech Group", "AI Discussion"]'
      IMAGE_CREATE_PREFIX: '["draw", "generate", "paint"]'
      CONVERSATION_MAX_TOKENS: 1000
      SPEECH_RECOGNITION: "False"
      CHARACTER_DESC: "An intelligent assistant powered by large language models, designed to answer questions and communicate in multiple languages."
      EXPIRES_IN_SECONDS: 3600
      USE_GLOBAL_PLUGIN_CONFIG: "True"
      USE_LINKAI: "False"
      LINKAI_API_KEY: ""
      LINKAI_APP_CODE: ""

The MODEL parameter accepts a custom identifier because the adapter resolves the actual bot target internally. Deploy the stack via the panel's compose execution feature.

WeChat Authentication

Open the runtime logs for the newly created Docker container. A QR code will appear in the log output. Scan this code with your designated secondary WeChat account to authorize the session. Following successful authentication, the bot will actively respond to group messages containing the configured trigger keywords.

Tags: WeChat Coze API Chatbot docker

Posted on Wed, 20 May 2026 05:11:52 +0000 by slicer123