# 上行消息

## 上行消息

### 响应参数

| 字段              | 数据类型   | 是否必填 | 描述                                                                                                                                                                                            |
| --------------- | ------ | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id              | String | 是    | 消息Id                                                                                                                                                                                          |
| accountName     | String | 是    | API账号名称                                                                                                                                                                                       |
| wabaId          | String | 是    | Waba Id                                                                                                                                                                                       |
| wamid           | String | 是    | Meta WhatApp消息Id                                                                                                                                                                              |
| from            | String | 是    | 用户手机号                                                                                                                                                                                         |
| to              | String | 是    | 商户手机号                                                                                                                                                                                         |
| sendTime        | String | 是    | 发送时间，格式：2023-02-22T12:00:00.000Z                                                                                                                                                              |
| customerProfile | JSON   | 是    | 用户信息                                                                                                                                                                                          |
| type            | String | 是    | 消息类型； text：文本消息 reaction：表情符号消息 image:图片消息 audio:音频消息 video:视频消息 sticker:贴纸消息 unknown：未知消息 location：位置消息 contacts：联系人消息 button：模板按钮回复消息 interactive：交互式消息/交互按钮回复消息 order：订单消息 system：用户更改号码通知 |
| text            | JSON   | 否    | type=text时有值                                                                                                                                                                                  |
| reaction        | JSON   | 否    | type=reaction时有值                                                                                                                                                                              |
| image           | JSON   | 否    | type=image时有值                                                                                                                                                                                 |
| audio           | JSON   | 否    | type=audio时有值                                                                                                                                                                                 |
| video           | JSON   | 否    | type=video时有值                                                                                                                                                                                 |
| errors          | JSON   | 否    | type=unknown时有值                                                                                                                                                                               |
| location        | JSON   | 否    | type=location时有值                                                                                                                                                                              |
| contacts        | JSON   | 否    | type=contacts时有值                                                                                                                                                                              |
| button          | JSON   | 否    | type=button时有值                                                                                                                                                                                |
| system          | JSON   | 否    | type=system时有值                                                                                                                                                                                |
| context         | JSON   | 否    | 上下文消息，引用消息回复时有值                                                                                                                                                                               |

### **text:回复示例**

| 字段        | 数据类型   | 是否必填 | 描述      |
| --------- | ------ | ---- | ------- |
| text.body | String | 是    | 表示回复的内容 |

```json
{
    "id": "b5e984b3-21b2-42a9-b08b-72e5a4096ac6",
    "type": "whatsapp_mo_message_received",
    "eventTime": "2023-02-22T12:00:00.000Z",
    "body": {
        "id": "63f5d602367ea403f8175a6c",
        "accountName": "IW123456",
        "wabaId": "WHATSAPP_BUSINESS_ACCOUNT_ID",
        "wamid": "wamid.BgNODYxN...",
        "from": "PHONE-NUMBER",
        "customerProfile": {
            "name": "Jack"
        },
        "to": "BUSINESS-PHONE-NUMBER",
        "sendTime": "2023-02-22T12:00:00.000Z",
        "type": "text",
        "text": {
            "body": "OK"
        }
    }
}
```

### **reaction:回复示例**

| 字段                 | 数据类型   | 是否必填 | 描述                   |
| ------------------ | ------ | ---- | -------------------- |
| reaction.messageId | String | 是    | 表示引用消息的wamid(原始消息id) |
| reaction.emoji     | String | 是    | 表示回复的表情符号            |
| sendTime           | String | 是    | 表示客户发送表情符号的时间        |

```json
{
    "id": "b5e984b3-21b2-42a9-b08b-72e5a4096ac6",
    "type": "whatsapp_mo_message_received",
    "eventTime": "2023-02-22T12:00:00.000Z",
    "body": {
        "id": "63f5d602367ea403f8175a6c",
        "accountName": "IW123456",
        "wabaId": "WHATSAPP_BUSINESS_ACCOUNT_ID",
        "wamid": "wamid.HBgNOD...",
        "from": "PHONE-NUMBER",
        "customerProfile": {
            "name": "Jack"
        },
        "to": "BUSINESS-PHONE-NUMBER",
        "sendTime": "2023-02-22T12:00:00.000Z",
        "type": "reaction",
        "reaction": {
            "messageId": "wamid.HBgNODY...",
            "emoji": "EMOJI"
        }
    }
}
```

| 字段             | 数据类型   | 是否必填 | 描述                |
| -------------- | ------ | ---- | ----------------- |
| image.caption  | String | 是    | 媒体描述或者标题          |
| image.mimeType | String | 是    | 媒体格式类型：image/jpeg |
| image.sha256   | String | 是    | 媒体资源文件Hash码       |
| image.link     | String | 是    | 媒体文件的下载链接         |

```json
{
    "id": "b5e984b3-21b2-42a9-b08b-72e5a4096ac6",
    "type": "whatsapp_mo_message_received",
    "eventTime": "2023-02-22T12:00:00.000Z",
    "body": {
        "id": "63f5d602367ea403f8175a6c",
        "accountName": "IW123456",
        "wabaId": "WHATSAPP_BUSINESS_ACCOUNT_ID",
        "wamid": "wamid.HBgNOD...",
        "from": "PHONE-NUMBER",
        "customerProfile": {
            "name": "Jack"
        },
        "to": "BUSINESS-PHONE-NUMBER",
        "sendTime": "2023-02-22T12:00:00.000Z",
        "type": "image",
        "image": {
            "caption": "CAPTION",
            "mimeType": "image/jpeg",
            "sha256": "IMAGE_HASH",
            "link": "http://xxxxxxxxxx"
        }
    }
}
```

### **sticker:回复示例**

| 字段               | 数据类型   | 是否必填 | 描述                |
| ---------------- | ------ | ---- | ----------------- |
| sticker.mimeType | String | 是    | 表情格式类型：image/webp |
| sticker.sha256   | String | 是    | 表情资源文件Hash码       |
| sticker.link     | String | 是    | 表情文件的下载链接         |

```json
{
    "id": "b5e984b3-21b2-42a9-b08b-72e5a4096ac6",
    "type": "whatsapp_mo_message_received",
    "eventTime": "2023-02-22T12:00:00.000Z",
    "body": {
        "id": "63f5d602367ea403f8175a6c",
        "accountName": "IW123456",
        "wabaId": "WHATSAPP_BUSINESS_ACCOUNT_ID",
        "wamid": "wamid.HBgNOD...",
        "from": "PHONE-NUMBER",
        "customerProfile": {
            "name": "Jack"
        },
        "to": "BUSINESS-PHONE-NUMBER",
        "sendTime": "2023-02-22T12:00:00.000Z",
        "type": "sticker",
        "sticker": {
            "mimeType": "image/webp",
            "sha256": "HASH",
            "link": "http://xxxxxxxxxx"
        }
    }
}
```

### **video:回复示例**

| 字段             | 数据类型   | 是否必填 | 描述               |
| -------------- | ------ | ---- | ---------------- |
| video.mimeType | String | 是    | 视频格式类型：video/mp4 |
| video.sha256   | String | 是    | 视频资源文件Hash码      |
| video.link     | String | 是    | 视频文件的下载链接        |

```json
{
    "id": "b5e984b3-21b2-42a9-b08b-72e5a4096ac6",
    "type": "whatsapp_mo_message_received",
    "eventTime": "2023-02-22T12:00:00.000Z",
    "body": {
        "id": "63f5d602367ea403f8175a6c",
        "accountName": "IW123456",
        "wabaId": "WHATSAPP_BUSINESS_ACCOUNT_ID",
        "wamid": "wamid.HBgNOD...",
        "from": "PHONE-NUMBER",
        "customerProfile": {
            "name": "Jack"
        },
        "to": "BUSINESS-PHONE-NUMBER",
        "sendTime": "2023-02-22T12:00:00.000Z",
        "type": "video",
        "video": {
            "mimeType": "video/mp4",
            "sha256": "G4fboj5cKcAbCdefzhcAcRdnXJqFJAyTSlNmJANhu4M=",
            "link": "http://xxxxxxxxxx"
        }
    }
}
```

### **Audio:回复示例**

| 字段             | 数据类型   | 是否必填 | 描述               |
| -------------- | ------ | ---- | ---------------- |
| audio.mimeType | String | 是    | 音频格式类型：video/mp4 |
| audio.sha256   | String | 是    | 音频资源文件Hash码      |
| audio.link     | String | 是    | 音频文件的下载链接        |

```json
{
    "id": "b5e984b3-21b2-42a9-b08b-72e5a4096ac6",
    "type": "whatsapp_mo_message_received",
    "eventTime": "2023-02-22T12:00:00.000Z",
    "body": {
        "id": "63f5d602367ea403f8175a6c",
        "accountName": "IW123456",
        "wabaId": "WHATSAPP_BUSINESS_ACCOUNT_ID",
        "wamid": "wamid.HBgNOD...",
        "from": "PHONE-NUMBER",
        "customerProfile": {
            "name": "Jack"
        },
        "to": "BUSINESS-PHONE-NUMBER",
        "sendTime": "2023-02-22T12:00:00.000Z",
        "type": "audio",
        "audio": {
            "mimeType": "audio/ogg; codecs=opus",
            "sha256": "ffRSAbcDeff3mJ2hBhpzuFY7pYEugTfglD+zx4Qv8X4=",
            "link": "http://xxxxxxxxxx"
        }
    }
}
```

### **Document:回复示例**

| 字段                | 数据类型   | 是否必填 | 描述               |
| ----------------- | ------ | ---- | ---------------- |
| document.mimeType | String | 是    | 文档格式类型：video/mp4 |
| document.sha256   | String | 是    | 文档资源文件Hash码      |
| document.link     | String | 是    | 文档文件的下载链接        |
| document.caption  | String | 是    | 文档描述或标题          |
| document.filename | String | 是    | 文档文件名称           |

```json
{
    "id": "b5e984b3-21b2-42a9-b08b-72e5a4096ac6",
    "type": "whatsapp_mo_message_received",
    "eventTime": "2023-02-22T12:00:00.000Z",
    "body": {
        "id": "63f5d602367ea403f8175a6c",
        "accountName": "IW123456",
        "wabaId": "WHATSAPP_BUSINESS_ACCOUNT_ID",
        "wamid": "wamid.HBgNOD...",
        "from": "PHONE-NUMBER",
        "customerProfile": {
            "name": "Jack"
        },
        "to": "BUSINESS-PHONE-NUMBER",
        "sendTime": "2023-02-22T12:00:00.000Z",
        "type": "document",
        "document": {
            "caption": "pdf caption",
            "filename": "filename.pdf",
            "mimeType": "application/pdf",
            "sha256": "TJGGMF5tdw3XApVHbABCdeffI7w4OW7GqYEN736PW0s=",
            "link": "http://xxxxxxxxxx"
        }
    }
}
```

### **Location:回复示例**

| 字段                 | 数据类型   | 是否必填 | 描述     |
| ------------------ | ------ | ---- | ------ |
| location.latitude  | String | 是    | 表示纬度   |
| location.longitude | String | 是    | 表示经度   |
| location.name      | String | 是    | 表示位置名称 |
| location.address   | String | 是    | 表示地址   |

```json
{
    "id": "b5e984b3-21b2-42a9-b08b-72e5a4096ac6",
    "type": "whatsapp_mo_message_received",
    "eventTime": "2023-02-22T12:00:00.000Z",
    "body": {
        "id": "63f5d602367ea403f8175a6c",
        "accountName": "IW123456",
        "wabaId": "WHATSAPP_BUSINESS_ACCOUNT_ID",
        "wamid": "wamid.HBgNOD...",
        "from": "PHONE-NUMBER",
        "customerProfile": {
            "name": "Jack"
        },
        "to": "BUSINESS-PHONE-NUMBER",
        "sendTime": "2023-02-22T12:00:00.000Z",
        "type": "location",
        "location": {
            "latitude": 39.90539,
            "longitude": 116.39134,
            "name": "LOCATION_NAME",
            "address": "LOCATION_ADDRESS",
        }
    }
}
```

### **Contact:回复示例**

```json
{
    "body": {
        "accountName": "IW31****5",
        "contact": [
            {
                "addresses": [
                    {
                        "city": "CONTACT_CITY1",
                        "country": "CONTACT_COUNTRY1",
                        "countryCode": "CONTACT_COUNTRY_CODE1",
                        "state": "CONTACT_STATE1",
                        "street": "CONTACT_STREET1",
                        "type": "HOME or WORK1",
                        "zip": "CONTACT_ZIP1"
                    }
                ],
                "birthday": "CONTACT_BIRTHDAY1",
                "emails": [
                    {
                        "email": "CONTACT_EMAIL1",
                        "type": "WORK or HOME1"
                    }
                ],
                "name": {
                    "firstName": "CONTACT_FIRST_NAME1",
                    "formattedName": "CONTACT_FORMATTED_NAME1",
                    "lastName": "CONTACT_LAST_NAME1",
                    "middleName": "CONTACT_MIDDLE_NAME1",
                    "prefix": "CONTACT_PREFIX1",
                    "suffix": "CONTACT_SUFFIX1"
                },
                "org": {
                    "company": "CONTACT_ORG_COMPANY1",
                    "department": "CONTACT_ORG_DEPARTMENT1",
                    "title": "CONTACT_ORG_TITLE1"
                },
                "phones": [
                    {
                        "phone": "CONTACT_PHONE1",
                        "type": "HOME or WORK>1",
                        "wa_id": "CONTACT_WA_ID1"
                    }
                ],
                "urls": [
                    {
                        "type": "HOME or WORK1",
                        "url": "CONTACT_URL1"
                    }
                ]
            }
        ],
        "customerProfile": {
            "name": "Jack"
        },
        "from": "86183****2197",
        "id": "a1301cb6d0094b2fae36546c22e09044",
        "sendTime": "2024-03-07T10:46:24.000Z",
        "to": "62811****6819",
        "type": "contacts",
        "wabaId": "1**********9",
        "wamid": "wamid.HBgNODYxODM1NTA5MjE5NxUCABIYIDg3RDVFMzQyRjIwQkM5NDQyMDI5OTRERERGNUYx*****=="
    },
    "eventTime": "2024-03-08T09:42:06.363Z",
    "id": "e2bafad5-0aa9-4465-9ed1-c5c01741c5e1",
    "type": "whatsapp_mo_message_received"
}
```

### **Button:回复示例**

客户点击互动消息模板中的快速回复按钮时，系统会发送响应。以下是回调格式示例。

| 字段           | 数据类型   | 是否必填 | 描述                                  |
| ------------ | ------ | ---- | ----------------------------------- |
| context.from | String | 是    | 是发送交互式消息的 WhatsApp ID（不带“+”前缀的电话号码） |
| context.id   | String | 是    | 是WhatsApp平台上的原始消息ID。                |

```json
{
    "id": "b5e984b3-21b2-42a9-b08b-72e5a4096ac6",
    "type": "whatsapp_mo_message_received",
    "eventTime": "2023-02-22T12:00:00.000Z",
    "body": {
        "id": "63f5d602367ea403f8175a6c",
        "accountName": "IW123456",
        "wabaId": "WHATSAPP_BUSINESS_ACCOUNT_ID",
        "wamid": "wamid.HBgNOD...",
        "from": "PHONE-NUMBER",
        "customerProfile": {
            "name": "Jack"
        },
        "to": "BUSINESS-PHONE-NUMBER",
        "sendTime": "2023-02-22T12:00:00.000Z",
        "type": "button",
        "button": {
            "text": "No",
            "payload": "No-Button-Payload"
        },
        "context": {
            "from": "PHONE_NUMBER",
            "id": "wamid.ID"
        }
    }
}
```

### **Unknown:回复示例**

&#x20; 您可能会收到未知的消息回调通知。例如，客户可能会给您发送不受支持的消息，如限时消息（在这种情况下，我们会通知客户消息类型不受支持）。

| 字段             | 数据类型   | 是否必填 | 描述     |
| -------------- | ------ | ---- | ------ |
| errors.code    | String | 是    | 表示错误码  |
| errors.details | String | 是    | 表示错误详情 |
| errors.title   | String | 是    | 表示错误名称 |

```json
{
    "id": "b5e984b3-21b2-42a9-b08b-72e5a4096ac6",
    "type": "whatsapp_mo_message_received",
    "eventTime": "2023-02-22T12:00:00.000Z",
    "body": {
        "id": "63f5d602367ea403f8175a6c",
        "accountName": "IW123456",
        "wabaId": "WHATSAPP_BUSINESS_ACCOUNT_ID",
        "wamid": "wamid.HBgNOD...",
        "from": "PHONE-NUMBER",
        "customerProfile": {
            "name": "Jack"
        },
        "to": "BUSINESS-PHONE-NUMBER",
        "sendTime": "2023-02-22T12:00:00.000Z",
        "type": "unknown",
        "errors": [
            {
                "code": 131051,
                "details": "Message type is not currently supported",
                "title": "Unsupported message type"
            }
        ]
    }
}
```

### **Interactive:回复示例**

当用户点击**您发送的清单消息中的某一项**时，您会收到以下 Webhooks 通知：

| 字段           | 数据类型   | 是否必填 | 描述                                  |
| ------------ | ------ | ---- | ----------------------------------- |
| context.from | String | 是    | 是发送交互式消息的 WhatsApp ID（不带“+”前缀的电话号码） |
| context.id   | String | 是    | 是WhatsApp平台上的原始消息ID。                |

```json
{
    "id": "b5e984b3-21b2-42a9-b08b-72e5a4096ac6",
    "type": "whatsapp_mo_message_received",
    "eventTime": "2023-02-22T12:00:00.000Z",
    "body": {
        "id": "63f5d602367ea403f8175a6c",
        "accountName": "IW123456",
        "wabaId": "WHATSAPP_BUSINESS_ACCOUNT_ID",
        "wamid": "wamid.HBgNOD...",
        "from": "PHONE-NUMBER",
        "customerProfile": {
            "name": "Jack"
        },
        "to": "BUSINESS-PHONE-NUMBER",
        "sendTime": "2023-02-22T12:00:00.000Z",
        "type": "interactive",
        "interactive": {
            "listReply": {
                "id": "list_reply_id",
                "title": "list_reply_title",
                "description": "list_reply_description"
            },
            "type": "listReply"
        },
        "context": {
            "from": "PHONE_NUMBER",
            "id": "wamid.ID"
        }
    }
}
```

当用户点击您发送的**回复按钮**时，您会收到以下 Webhooks 通知：

```json
{
    "id": "b5e984b3-21b2-42a9-b08b-72e5a4096ac6",
    "type": "whatsapp_mo_message_received",
    "eventTime": "2023-02-22T12:00:00.000Z",
    "body": {
        "id": "63f5d602367ea403f8175a6c",
        "accountName": "IW123456",
        "wabaId": "WHATSAPP_BUSINESS_ACCOUNT_ID",
        "wamid": "wamid.HBgNOD...",
        "from": "PHONE-NUMBER",
        "customerProfile": {
            "name": "Jack"
        },
        "to": "BUSINESS-PHONE-NUMBER",
        "sendTime": "2023-02-22T12:00:00.000Z",
        "type": "interactive",
        "interactive": {
            "buttonReply": {
                "id": "unique-button-identifier-here",
                "title": "button-text"
            },
            "type": "buttonReply"
        },
         "context": {
            "from": "PHONE_NUMBER",
            "id": "wamid.ID"
        }
    }
}
```
