简体中文 English 繁體中文 日本語 Русский
本文为静态镜像,内容以交互版为准 在交互式文档中心打开 →

Supported Platform Capabilities

v5 Paradigm Update (4.2.0)

Platform Feature Description — Webhook Universal Bridge Adapter

This document provides a detailed explanation of the bidirectional bridge protocol, field mapping, and implementation features of the Webhook adapter.

Overview

The Webhook Adapter is a protocol-level bridge, not tied to any specific platform. It exchanges messages via HTTP, enabling any system capable of initiating HTTP requests to integrate with ErisPulse.

Inbound Direction                          Outbound Direction
────────────────                          ────────────────
External System                            ErisPulse Module
   │                                         │
   │ POST JSON                               │ Send.Text(...)
   ▼                                         ▼
┌──────────────────────────────────────────────────────┐
│                WebhookAdapter                          │
│  ┌──────────────────┐    ┌──────────────────┐     │
│  │ Inbound Routes    │    │ Outbound Forward │     │
│  │ GET  (Health Check)│    │ client.post()    │     │
│  │ POST (Receive Event)│   │ → outgoing_url   │     │
│  └────────┬─────────┘    └────────▲─────────┘     │
│           │                      │                 │
│           ▼                      │                 │
│  ┌──────────────────┐    ┌──────────────────┐     │
│  │ WebhookConverter │    │ Send Class       │     │
│  │ JSON → OneBot12  │    │ Message Segment → JSON │
│  └────────┬─────────┘    └────────▲─────────┘     │
└───────────┼──────────────────────┼─────────────────┘
            ▼                      │
     adapter.emit(event)    call_api("send_message")
            │                      │
            ▼                      │
       ErisPulse Event System ◄────────┘

Multi-Account Model

Each account is an independent bridge configuration, isolated from each other:

Account bot_id callback_path outgoing_url secret
default webhook_bot /webhook/default https://a.com/recv key1
discord discord_bot /webhook/discord https://b.com/send key2

Each account registers routes independently and emits connect independently upon startup.

Inbound Protocols

1. Health Check (GET)

{"status": "ok", "account": "default"}

2. Receive Event (POST)

Request Body

{
  "user_id": "u123",
  "user_nickname": "用户名",
  "group_id": "群组ID(仅群组会话)",
  "detail_type": "private",
  "message": [
    {"type": "text", "data": {"text": "消息内容"}}
  ],
  "raw": {}
}
Field Required Description
user_id Yes Sender ID
user_nickname No Sender nickname
group_id No Group/channel ID (provided for group sessions)
detail_type No Session type (private/group), defaults to account default if missing
message Yes Array of OneBot12 message segments
raw No Raw data, stored as-is in webhook_raw

Response

{"status": "ok"}

Error responses include HTTP status codes:

Status Code Meaning
400 Invalid JSON / body is not an object
401 Authentication failed
404 Unknown account
500 Event dispatch failed

3. Field Mapping (Inbound JSON → OneBot12 Event)

Inbound JSON OneBot12 Event Field Description
— id Auto-generated
— time Current Unix timestamp (seconds)
— type Fixed as message
detail_type detail_type Defaults to account default value if missing
— platform Fixed as webhook
— self.platform Fixed as webhook
— self.user_id Account bot_id
user_id user_id Passed through
user_nickname user_nickname Passed through (optional)
group_id group_id Passed through (optional)
message message Passed through
Full body webhook_raw Original request
Account name webhook_account Name of the account that generated the event
type or message webhook_raw_type Original event type

Outbound Protocols

1. Sending Messages

When the module calls methods such as Send.To(...).Text(...), the adapter sends a POST request to outgoing_url:

Request Body

{
  "target_type": "private",
  "target_id": "target_user_id",
  "account": "default",
  "message": [
    {"type": "text", "data": {"text": "Message content"}}
  ],
  "timestamp": 1700000000
}
Field Description
target_type Target type (from Send.To(type, id)), defaults to the account's default if not provided
target_id Target ID (from Send.To)
account Sender account name
message Array of OneBot12 message segments
timestamp Timestamp of sending (in seconds)

2. Response Standardization

The adapter standardizes the response from the outbound target into the ErisPulse standard response format:

{
  "status": "ok",
  "retcode": 0,
  "data": {"message_id": "...", ...},
  "message_id": "...",
  "message": "",
  "webhook_raw": {}
}

The message ID is extracted from the message_id field of the target's response JSON. If the target does not return a message_id, it will be an empty string.

If the request fails, an error response is returned (with status: "failed", retcode: 33001).

Send Method

Method Description
Text(text) Sends text, encapsulated as [{"type":"text","data":{"text":text}}]
Image(file) Sends an image, encapsulated as [{"type":"image","data":{"file":file}}]
Raw_ob12(message) Sends a raw OneBot12 message segment
Json(data) Passes raw JSON data, encapsulated as [{"type":"json","data":{"raw":data}}]

At / AtAll / Reply decorators are provided by the framework base class and merged into message segments via _apply_modifiers.

Event Extension Methods (WebhookEventMixin)

Method Description
get_raw_data() Get the raw request body (webhook_raw)
get_detail_type() Get the session type
get_webhook_account() Get the account name that generated the event

Feature Matrix

Feature Support Status
Multi-account ✅ Each account has an independent bridge
Inbound Authentication ✅ Header / Query dual mode
Health Check ✅ GET returns status
Outbound Authentication ✅ Secret carried in Header
OneBot12 Standard Events ✅ Complete standard fields
Meta Events ✅ connect / disconnect
Route Discovery ✅ Registered to webhook namespace
WebSocket ❌ Only HTTP
Media Upload ❌ Pass-through via URL, no binary relay

Notes

  1. One-way Outbound: If outgoing_url is left empty, the account will only receive inbound messages, and sending operations will return an error.
  2. Secret Security: secret is stored as an encrypted value in the configuration (metadata secret), and HTTPS is recommended for transmission.
  3. Unique Path: The callback_path for multiple accounts must be unique to avoid routing conflicts.
  4. Idempotency: The adapter does not guarantee deduplication of inbound events; external systems should handle retries themselves.
  5. Timeout: Outbound requests use ErisPulse's built-in client and inherit the global timeout configuration.