API 参考
接收事件

message.received

账号收到一条入站消息。

按消息类型的载荷

Text

{
  "id": "evt_2f9c1a4b7e",
  "type": "message.received",
  "provider": "whatsapp",
  "account_id": "acc_8c21d0",
  "occurred_at": "2026-06-08T12:34:56Z",
  "data": {
    "conversation": { "id": "8613912345678", "type": "user" },
    "sender": { "id": "8613912345678", "type": "user", "name": "Jordan Lee" },
    "message": {
      "id": "wamid.HBgM",
      "type": "text",
      "text": "Hi - is my order shipped yet?",
      "direction": "inbound",
      "sent_at": "2026-06-08T12:34:55Z"
    },
    "event": { "kind": "message_received" }
  }
}

Image (with caption)

{
  "id": "evt_4a1c7b9e2f",
  "type": "message.received",
  "provider": "whatsapp",
  "account_id": "acc_8c21d0",
  "occurred_at": "2026-06-08T12:35:02Z",
  "data": {
    "conversation": { "id": "8613912345678", "type": "user" },
    "sender": { "id": "8613912345678", "type": "user", "name": "Jordan Lee" },
    "message": {
      "id": "wamid.HBgN",
      "type": "image",
      "text": "Here's the unboxing photo",
      "direction": "inbound",
      "sent_at": "2026-06-08T12:35:02Z",
      "attachments": [
        {
          "type": "image",
          "url": "https://unifyport-media.oss-cn-hongkong.aliyuncs.com/pro/1/whatsapp/10001/2a1f.jpg?Expires=1749384902&Signature=...",
          "mimetype": "image/jpeg"
        }
      ]
    },
    "event": { "kind": "message_received" }
  }
}

Voice / Audio

{
  "id": "evt_6b2d8c0f3a",
  "type": "message.received",
  "provider": "whatsapp",
  "account_id": "acc_8c21d0",
  "occurred_at": "2026-06-08T12:35:20Z",
  "data": {
    "conversation": { "id": "8613912345678", "type": "user" },
    "sender": { "id": "8613912345678", "type": "user", "name": "Jordan Lee" },
    "message": {
      "id": "wamid.HBgO",
      "type": "audio",
      "direction": "inbound",
      "sent_at": "2026-06-08T12:35:20Z",
      "attachments": [
        {
          "type": "audio",
          "url": "https://unifyport-media.oss-cn-hongkong.aliyuncs.com/pro/1/whatsapp/10001/9c3e.ogg?Expires=1749384920&Signature=...",
          "mimetype": "audio/ogg; codecs=opus",
          "duration_ms": 8000
        }
      ]
    },
    "event": { "kind": "message_received" }
  }
}

Document (large file — url omitted)

{
  "id": "evt_7c3e9d1a4b",
  "type": "message.received",
  "provider": "whatsapp",
  "account_id": "acc_8c21d0",
  "occurred_at": "2026-06-08T12:35:45Z",
  "data": {
    "conversation": { "id": "8613912345678", "type": "user" },
    "sender": { "id": "8613912345678", "type": "user", "name": "Jordan Lee" },
    "message": {
      "id": "wamid.HBgP",
      "type": "document",
      "direction": "inbound",
      "sent_at": "2026-06-08T12:35:45Z",
      "attachments": [
        {
          "type": "document",
          "mimetype": "application/pdf",
          "title": "invoice-A1234.pdf",
          "metadata": { "is_big_file": true, "size": 87421133 }
        }
      ]
    },
    "event": { "kind": "message_received" }
  }
}

Location

{
  "id": "evt_8d4f0e2b5c",
  "type": "message.received",
  "provider": "whatsapp",
  "account_id": "acc_8c21d0",
  "occurred_at": "2026-06-08T12:36:10Z",
  "data": {
    "conversation": { "id": "8613912345678", "type": "user" },
    "sender": { "id": "8613912345678", "type": "user", "name": "Jordan Lee" },
    "message": {
      "id": "wamid.HBgQ",
      "type": "location",
      "text": "Shibuya Scramble Square, 2-24-12 Shibuya, Tokyo",
      "direction": "inbound",
      "sent_at": "2026-06-08T12:36:10Z"
    },
    "event": { "kind": "message_received" }
  }
}

备注

  • data.conversation 是会话,data.sender 是发送者,data.message 是消息内容——id、type、text、direction(这里恒为 inbound)和 sent_at。Telegram 还会带 conversation.title、sender.username 以及 account 块;具体字段按 provider 而异。
  • data.message.type 取值为 text / image / video / audio / document / sticker / location / contact 之一(或 unknown)。媒体类型(image / video / audio / document / sticker)带 data.message.attachments[];video 和 audio 多一个 duration_ms,document 带文件名 title,超大文件会置 attachments[].metadata.is_big_file 且省略 url。location 与 contact 没有附件——内容在 data.message.text 里(contact 是 vCard)。