Help Center
Configure Smart Robots via Long Connection

1. Overview

What is a Long Connection?

Long connection (WebSocket) refers to a persistent, bidirectional communication channel initiated and maintained by the developer’s server to WeCom.
If you want to quickly integrate OpenClaw via long connection, please refer to: Integrate OpenClaw via Long Connection.

Technical Core Mechanism

1. Secure handshake: Establishes a connection based on the wss:// protocol, with built-in encryption at the underlying layer. The business layer does not need to handle complex message encryption and decryption.
2. Credential subscription: After the connection is established, the aibot_subscribe command must be sent, completing identity verification using the robot’s unique BotID and Secret.
3. Heartbeat Keep-Alive: As it is a persistent connection, developers need to periodically (recommended every 30 seconds) send a heartbeat (ping) to prevent the connection from being terminated by the gateway.
4. Native streaming response: Perfectly matches the typing-style output effect of Large Language Models (LLM). Developers can push content in segments until setting finish=true to end the streaming output, eliminating the need for frequent refreshing.

Applicable Scenes

  • Intranet deployment: No fixed public IP or exposed URL is required. The connection is actively established from the intranet outward, effectively penetrating firewalls and enhancing company data security.
  • Ultra-low latency: Eliminates the handshake overhead for each communication, providing extremely high real-time performance, making it ideal for the AI-powered real-time chat assistant.
  • Simplified development: Removes the cumbersome steps of configuring URLs, validating tokens, and decrypting messages required in the traditional Webhook mode.

    Please securely store your Bot ID and Secret, and do not disclose them to others easily.

2. Developer Documentation

If you are a developer, you can refer to: WeCom Developer Documentation