# whatsapp消息入口

## whatsapp消息入口，推送消息给所有接收者 <a href="#whatsapp-message-inner" id="whatsapp-message-inner"></a>

当whatsapp公众号发送消息时相当于bot发送消息。可接收多渠道发来的消息。当用户发送消息时，Bot将此消息推送给所有接收者。接收者可以定义为接收bot信息，或接收livechat信息。( 如想要变为接收者请与我们联系 )

### 发送请求

Bot向所有接收者发起推送，推送请求的说明如下：

| 请求属性      | 属性名       | 说明                              |
| --------- | --------- | ------------------------------- |
| 请求方式      | POST      |                                 |
| Form Data | id        | 由WhatsApp分配的消息ID                |
| Form Data | to        | channel的手机号                     |
| Form Data | from      | 客户的手机号                          |
| Form Data | timestamp | 信息发送的时间戳                        |
| Form Data | type      | 消息类型（text,image,document,voice） |
| Form Data | text      | 当type=text 时显示。形式会在下方详述。        |
| Form Data | image     | 当type=image 时显示。形式会在下方详述。       |
| Form Data | document  | 当type=document 时显示。形式会在下方详述。    |
| Form Data | voice     | 当type=voice 时显示。形式会在下方详述。       |

### **请求样例**

{% code title="Text message" %}

```javascript
{
    "id": "<unique message identifier>",
    "from": "<phone number of the channel>",
    "to": "<phone number of the user>",
    "timestamp": "<timestamp>",
    "type": "text",
    "text": {
        "body": "Hello world"
    }
}
```

{% endcode %}

{% code title="Image message" %}

```javascript
{
    "id": "<unique message identifier>",
    "from": "<phone number of the channel>",
    "to": "<phone number of the user>",
    "timestamp": "<timestamp>",
    "type": "image",
    "image": {
        "url": "your-media-url",
        "caption": "your-image-caption",
        "mimeType": "<see the list of available mimeType>"
    }
}
```

{% endcode %}

{% code title="Document message" %}

```javascript
{
    "id": "<unique message identifier>",
    "from": "<phone number of the channel>",
    "to": "<phone number of the user>",
    "timestamp": "<timestamp>",
    "type": "document",
    "document": {
        "url": "your-document-url",
        "caption": "your-document-caption",
        "mimeType": "<see the list of available mimeType>"
    }
}
```

{% endcode %}

{% code title="Voice message" %}

```javascript
{
    "id": "<unique message identifier>",
    "from": "<phone number of the channel>",
    "to": "<phone number of the user>",
    "timestamp": "<timestamp>",
    "type": "voice",
    "voice": {
        "url": "your-voice-url",
        "mimeType": "<see the list of available mimeType>"
    }
}
```

{% endcode %}

### 请求返回值

* 成功返回值样例

```javascript
{
    "status": 200,
    "data": {}
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bothub.gitbook.io/project/whatsapp-xiang-guan-shuo-ming/whatsapp-xiao-xi-ru-kou.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
