Skip to main content

新消息回调

回调地址

  • 需要在 INCS 设置您的回调地址

回调请求方式

  • POST

回调内容

参数说明

参数名 类型 必传 描述
event string 回调事件名称,这里为 "new_message"
business_phone string whatsapp business phone number
message object WhatsApp 消息内容,不同的消息内容会有所差别
message Object
 
Name Description
contactsarray of objects Array of contact objects with information for the customer who sent a message to the business. Contact objects have the following properties: wa_idString. The customer's WhatsApp ID. A business can respond to a customer using this ID. This ID may not match the customer's phone number, which is returned by the API as input when sending a message to the customer.profileObject. A customer profile object. Profile objects have the following properties:nameString. The customer's name.
errorsarray of objects An array of error objects describing the error. Error objects have the following properties. Webhooks triggered by v15.0 and older requests: codeInteger. Example: 130429.titleString. Error code title. Example: Rate limit hit.Webhooks triggered by v16.0 and newer requests: codeInteger. Error code. Example: 130429.titleString. Error code title. Example: Rate limit hit.messageString. Error code message. This value is the same as the title value. For example: Rate limit hit. Note that the message property in API error response payloads pre-pends this value with the a # symbol and the error code in parenthesis. For example: (#130429) Rate limit hit.error_dataObject. An error data object with the following properties: detailsString. Describes the error. Example: Message failed to send because there were too many messages sent from this phone number in a short period of time.
messaging_productstring Product used to send the message. Value is always whatsapp.
messagesarray of objects Information about a message received by the business that is subscribed to the webhook.
metadataobject A metadata object describing the business subscribed to the webhook. Metadata objects have the following properties: display_phone_numberString. The phone number that is displayed for a business.phone_number_idString. ID for the phone number. A business can respond to a message using this ID.
statusesarray of objects Status object for a message that was sent by the business that is subscribed to the webhook.

Messages Objects

The messages array of objects is nested within the value object and is triggered when a customer updates their profile information or a customer sends a message to the business that is subscribed to the webhook.

Name Description
audioobject When the messages type is set to audio, including voice messages, this object is included in the messages object: idString. ID for the audio file.mime_typeString. Mime type of the audio file.
buttonobject When the messages type field is set to button, this object is included in the messages object: payloadString. The payload for a button set up by the business that a customer clicked as part of an interactive message.textString. Button text.
contextobject Context object. Only included when a user replies or interacts with one of your messages. Context objects can have the following properties: forwardedBoolean. Set to true if the message received by the business has been forwarded.frequently_forwardedBoolean. Set to true if the message received by the business has been forwarded more than 5 times.fromString. The WhatsApp ID for the customer who replied to an inbound message.idString. The message ID for the sent message for an inbound reply.referred_productObject. Referred product object describing the product the user is requesting information about. You must parse this value if you support Product Enquiry Messages. Referred product objects have the following properties:catalog_idString. Unique identifier of the Meta catalog linked to the WhatsApp Business Account.product_retailer_idString. Unique identifier of the product in a catalog.
documentobject A document object. When messages type is set to document, this object is included in the messages object. Document objects can have the following properties: captionString. Caption for the document, if provided.filenameString. Name for the file on the sender's device.sha256String. SHA 256 hash.mime_type — _String. _ Mime type of the document file.idString. ID for the document.
errorsarray of objects An array of error objects describing the error. Error objects have the following properties. Webhooks triggered by v15.0 and older requests: codeInteger. Example: 130429.titleString. Error code title. Example: Rate limit hit.Webhooks triggered by v16.0 and newer requests: codeInteger. Error code. Example: 130429.titleString. Error code title. Example: Rate limit hit.messageString. Error code message. This value is the same as the title value. For example: Rate limit hit. Note that the message property in API error response payloads pre-pends this value with the a # symbol and the error code in parenthesis. For example: (#130429) Rate limit hit.error_dataObject. An error data object with the following properties: detailsString. Describes the error. Example: Message failed to send because there were too many messages sent from this phone number in a short period of time.
fromstring The customer's WhatsApp ID. A business can respond to a customer using this ID. This ID may not match the customer's phone number, which is returned by the API as input when sending a message to the customer.
idstring The ID for the message that was received by the business.
identityobject An identity object. See messages system identity. Identity objects can have the following properties: acknowledged — State of acknowledgment for the messages system customer_identity_changed.created_timestampString. The time when the WhatsApp Business Management API detected the customer may have changed their profile information.hashString. The ID for the messages system customer_identity_changed
imageobject When messages type is set to image, this object is included in the messages object. captionString. Caption for the image, if provided.sha256String. Image hash.idString. ID for the image.mime_typeString. Mime type for the image.
interactiveobject When a customer has interacted with your message, this object is included in the messagesobject. Interactive objects have the following properties: type — Object with the following properties:button_reply – Sent when a customer clicks a button. Object with the following properties:idString. Unique ID of a button.titleString. Title of a button.list_reply — Sent when a customer selects an item from a list. Object with the following properties:idString. Unique ID of the selected list item.titleString. Title of the selected list item.descriptionString. Description of the selected row.
orderobject Included in the messages object when a customer has placed an order. Order objects have the following properties: catalog_idString. ID for the catalog the ordered item belongs to.textString. Text message from the user sent along with the order.product_items — Array of product item objects containing the following fields:product_retailer_idString. Unique identifier of the product in a catalog.quantityString. Number of items.item_priceString. Price of each item.currencyString. Price currency.
referralobject Referral object. When a customer clicks an ad that redirects to WhatsApp, this object is included in the messages object. Referral objects have the following properties: source_urlString. The Meta URL that leads to the ad or post clicked by the customer. Opening this url takes you to the ad viewed by your customer.source_typeString. The type of the ad’s source; ad or post.source_idString. Meta ID for an ad or a post.headlineString. Headline used in the ad or post.bodyString. Body for the ad or post.media_typeString. Media present in the ad or post; image or video.image_urlString. URL of the image, when media_type is an image.video_urlString. URL of the video, when media_type is a video.thumbnail_urlString. URL for the thumbnail, when media_type is a video.ctwa_clidString. Click ID generated by Meta for ads that click to WhatsApp.The referral object can be included in the following types of message: text, location, contact, image, video, document, voice, and sticker.Click-to-WhatsApp ads are only supported in the Android and iOS apps. If the customer is using the Web browser or their computer to click on an ad, then the resulting webhook will contain a referral object without some of the above properties.
stickerobject When messages type is set to sticker, this object is included in the messages object. Sticker objects have the following properties: mime_typeString. image/webp.sha256String. Hash for the sticker.idString. ID for the sticker.animatedBoolean. Set to true if the sticker is animated; false otherwise.
systemobject When messages type is set to system, a customer has updated their phone number or profile information, this object is included in the messages object. System objects have the following properties: bodyString. Describes the change to the customer's identity or phone number.identityString. Hash for the identity fetched from server.new_wa_idString. New WhatsApp ID for the customer when their phone number is updated. Available on webhook versions v11.0 and earlier.wa_idString. New WhatsApp ID for the customer when their phone number is updated. Available on webhook versions v12.0 and later.typeString. Type of system update. Will be one of the following:.customer_changed_number – A customer changed their phone number.customer_identity_changed – A customer changed their profile information.customerString. The WhatsApp ID for the customer prior to the update.group_id - String. If set, corresponds to which thread the system message was sent in. If you share multiple groups with this user, you will receive multiple webhooks.
textobject When messages type is set to text, this object is included. Text objects have the following properties: bodyString. The text of the message.
timestampstring Unix timestamp indicating when the WhatsApp server received the message from the customer.
typestring The type of message that has been received by the business that has subscribed to Webhooks. Possible value can be one of the following: audio``button``document``text``image``interactive``order``sticker``system – for customer number change messagesunknown``video
videoobject When messages type is set to video, this object is included in messages object. Video objects have the following properties: captionString. The caption for the video, if provided.sha256String. The hash for the video.idString. The ID for the video.mime_typeString. The mime type for the video file.

回调示例

text 纯文本
{
    "event": "new_message",
    "business_phone": "6281519236680",
    "message": {
        "messaging_product": "whatsapp",
        "metadata": {
            "display_phone_number": "6281519236680",
            "phone_number_id": "302702419599374"
        },
        "contacts": [ // 发信人信息
            {
                "profile": {
                    "name": "Lessie Laytoya"
                },
                "wa_id": "85268415026"
            }
        ],
        "messages": [
            {
                "from": "85268415026",
                "id": "wamid.HBgLODUyNjg0MTUwMjYVAgASGBQzQUY1Qjc4MUQzNjM3OTk1QUVENQA=",
                "timestamp": "1756109460",
                "text": {
                    "body": "hello"
                },
                "type": "text"
            }
        ]
    }
}
reaction 引用回复
{
    "event": "new_message",
    "business_phone": "6281519236680",
    "message": {
        "messaging_product": "whatsapp",
        "metadata": {
            "display_phone_number": "6281519236680",
            "phone_number_id": "302702419599374"
        },
        "contacts": [
            {
                "profile": {
                    "name": "Lessie Laytoya"
                },
                "wa_id": "85268415026"
            }
        ],
        "messages": [
            {
                "context": { // 引用的消息
                    "from": "6281519236680",
                    "id": "wamid.HBgLODUyNjg0MTUwMjYVAgARGBI5RkEyNjU2NEUwMDhBRDMxNTEA"
                },
                "from": "85268415026",
                "id": "wamid.HBgLODUyNjg0MTUwMjYVAgASGBQzQTY5OUZERjU5MDZBQzUyN0Y0MgA=",
                "timestamp": "1756113398",
                "text": {
                    "body": "OK"
                },
                "type": "text"
            }
        ]
    }
}
image 图片
{
    "event": "new_message",
    "business_phone": "6281519236680",
    "message": {
        "messaging_product": "whatsapp",
        "metadata": {
            "display_phone_number": "6281519236680",
            "phone_number_id": "302702419599374"
        },
        "contacts": [
            {
                "profile": {
                    "name": "Lessie Laytoya"
                },
                "wa_id": "85268415026"
            }
        ],
        "messages": [
            {
                "from": "85268415026",
                "id": "wamid.HBgLODUyNjg0MTUwMjYVAgASGBQzQUZCMzlCREIwMDdCMkYzRjZBQgA=",
                "timestamp": "1756111162",
                "type": "image",
                "image": {
                    "mime_type": "image\/jpeg",
                    "sha256": "X+rJ8sVYdTYG9nD3JOGjJAb4GE3qw89S8kQNQ2fRj1w=",
                    "id": "2173590463051074",
                    "link": "https:\/\/static.incsapp.com\/chat\/images\/2173590463051074.jpg"
                }
            }
        ]
    }
}
sticker 贴纸
{
    "event": "new_message",
    "business_phone": "6281519236680",
    "message": {
        "messaging_product": "whatsapp",
        "metadata": {
            "display_phone_number": "6281519236680",
            "phone_number_id": "302702419599374"
        },
        "contacts": [
            {
                "profile": {
                    "name": "Lessie Laytoya"
                },
                "wa_id": "85268415026"
            }
        ],
        "messages": [
            {
                "from": "85268415026",
                "id": "wamid.HBgLODUyNjg0MTUwMjYVAgASGBQzQUM4MzBCOUIzNTk4RTI1MUE5OQA=",
                "timestamp": "1756111078",
                "type": "sticker",
                "sticker": {
                    "mime_type": "image\/webp",
                    "sha256": "1RgjeZcCQQjyzYnvcvInvzes\/n9ThHJ4Ndr3dzGUeP0=",
                    "id": "782472500814983",
                    "animated": false,
                    "link": "https:\/\/static.incsapp.com\/chat\/images\/782472500814983.webp"
                }
            }
        ]
    }
}
video 视频
{
    "event": "new_message",
    "business_phone": "6281519236680",
    "message": {
        "messaging_product": "whatsapp",
        "metadata": {
            "display_phone_number": "6281519236680",
            "phone_number_id": "302702419599374"
        },
        "contacts": [
            {
                "profile": {
                    "name": "Lessie Laytoya"
                },
                "wa_id": "85268415026"
            }
        ],
        "messages": [
            {
                "from": "85268415026",
                "id": "wamid.HBgLODUyNjg0MTUwMjYVAgASGBQzQTA3Qzg2MTAyQTgxRDBCQkQ0RgA=",
                "timestamp": "1756111347",
                "type": "video",
                "video": {
                    "caption": "beautiful\uff1f", // 用户添加的描述
                    "mime_type": "video\/mp4",
                    "sha256": "8m71YIxOHqc3HYGthZiquLeeE0N1Cv0MeTc25ahf4sU=",
                    "id": "1277927410543839",
                    "link": "https:\/\/static.incsapp.com\/chat\/videos\/1277927410543839.mp4"
                }
            }
        ]
    }
}
audio 语音
{
    "event": "new_message",
    "business_phone": "6281519236680",
    "message": {
        "messaging_product": "whatsapp",
        "metadata": {
            "display_phone_number": "6281519236680",
            "phone_number_id": "302702419599374"
        },
        "contacts": [
            {
                "profile": {
                    "name": "Lessie Laytoya"
                },
                "wa_id": "85268415026"
            }
        ],
        "messages": [
            {
                "from": "85268415026",
                "id": "wamid.HBgLODUyNjg0MTUwMjYVAgASGBQzQUFBQzc3RUVCQTRCNDMxOTNBMgA=",
                "timestamp": "1756112512",
                "type": "audio",
                "audio": {
                    "mime_type": "audio\/ogg; codecs=opus",
                    "sha256": "pp0SvItSzmvP6mRp1mR\/4tn9ydbnv72YWiZ9XxaxTZg=",
                    "id": "1082985930630339",
                    "voice": true,
                    "link": "https:\/\/static.incsapp.com\/chat\/audios\/1082985930630339.ogg"
                }
            }
        ]
    }
}
document 文档
{
    "event": "new_message",
    "business_phone": "6281519236680",
    "message": {
        "messaging_product": "whatsapp",
        "metadata": {
            "display_phone_number": "6281519236680",
            "phone_number_id": "302702419599374"
        },
        "contacts": [
            {
                "profile": {
                    "name": "Lessie Laytoya"
                },
                "wa_id": "85268415026"
            }
        ],
        "messages": [
            {
                "from": "85268415026",
                "id": "wamid.HBgLODUyNjg0MTUwMjYVAgASGBQzQTg3MUUyRjA4RDA3RTdFQzUyNwA=",
                "timestamp": "1756112790",
                "type": "document",
                "document": {
                    "filename": "email_template_en.xls",
                    "mime_type": "application\/vnd.ms-excel",
                    "sha256": "0WWrm0sDQYStNhqArO7uRiViw40SbSP+QALrNGyi4pE=",
                    "id": "797337589311657",
                    "link": "https:\/\/static.incsapp.com\/chat\/files\/797337589311657.xls"
                }
            }
        ]
    }
}
contacts 联系人
{
    "event": "new_message",
    "business_phone": "6281519236680",
    "message": {
        "messaging_product": "whatsapp",
        "metadata": {
            "display_phone_number": "6281519236680",
            "phone_number_id": "302702419599374"
        },
        "contacts": [
            {
                "profile": {
                    "name": "Lessie Laytoya"
                },
                "wa_id": "85268415026"
            }
        ],
        "messages": [
            {
                "from": "85268415026",
                "id": "wamid.HBgLODUyNjg0MTUwMjYVAgASGBQzQTdCQzYyMEM0NjcxQkYzN0VFOQA=",
                "timestamp": "1756112662",
                "type": "contacts",
                "contacts": [
                    {
                        "name": {
                            "first_name": "Lessie Laytoya",
                            "formatted_name": "Lessie Laytoya"
                        },
                        "phones": [
                            {
                                "phone": "+85268415026",
                                "wa_id": "85268415026",
                                "type": "CELL"
                            }
                        ]
                    }
                ]
            }
        ]
    }
}
button 按钮选项
{
    "event": "new_message",
    "business_phone": "6281519236680",
    "message": {
        "messaging_product": "whatsapp",
        "metadata": {
            "display_phone_number": "6281519236680",
            "phone_number_id": "302702419599374"
        },
        "contacts": [
            {
                "profile": {
                    "name": "Lessie Laytoya"
                },
                "wa_id": "85268415026"
            }
        ],
        "messages": [
            {
                "context": { // 选项关联的某条消息
                    "from": "6281519236680",
                    "id": "wamid.HBgLODUyNjg0MTUwMjYVAgARGBJGNDY4NjdEN0I3QkZCMzg5QjMA"
                },
                "from": "85268415026",
                "id": "wamid.HBgLODUyNjg0MTUwMjYVAgASGBQzQUM5MzJGN0EwRThCNTgyRTVFNAA=",
                "timestamp": "1756112962",
                "type": "button",
                "button": {
                    "payload": "\u8fd8\u6709\u5176\u4ed6\u95ee\u9898",
                    "text": "\u8fd8\u6709\u5176\u4ed6\u95ee\u9898"
                }
            }
        ]
    }
}
location 位置
{
    "event": "new_message",
    "business_phone": "6281519236680",
    "message": {
        "messaging_product": "whatsapp",
        "metadata": {
            "display_phone_number": "6281519236680",
            "phone_number_id": "302702419599374"
        },
        "contacts": [
            {
                "profile": {
                    "name": "Lessie Laytoya"
                },
                "wa_id": "85268415026"
            }
        ],
        "messages": [
            {
                "from": "85268415026",
                "id": "wamid.HBgLODUyNjg0MTUwMjYVAgASGBQzQTczMTRCMzNDNjgwMzExNkUyNgA=",
                "timestamp": "1756113235",
                "location": {
                    "latitude": 22.570337295532,
                    "longitude": 113.87411499023,
                    "name": "\u534e\u4e30\u91d1\u878d\u6e2f" // 选填
                },
                "type": "location"
            }
        ]
    }
}
order 订单
  • A WhatsApp user orders one or more products via a catalog, single-, or multi-product message.
{
    "event": "new_message",
    "business_phone": "6281519236680",
    "message": {
        "messaging_product": "whatsapp",
        "metadata": {
            "display_phone_number": "15550783881",
            "phone_number_id": "106540352242922"
        },
        "contacts": [
            {
                "profile": {
                    "name": "Sheena Nelson"
                },
                "wa_id": "16505551234"
            }
        ],
        "messages": [
            {
                "from": "16505551234",
                "id": "wamid.HBgLMTY1MDM4Nzk0MzkVAgASGBQzQUFERjg0NDEzNDdFODU3MUMxMAA=",
                "timestamp": "1750096325",
                "type": "order",
                "order": {
                    "catalog_id": "194836987003835",
                    "text": "Love these!",
                    "product_items": [
                        {
                            "product_retailer_id": "di9ozbzfi4",
                            "quantity": 2,
                            "item_price": 30,
                            "currency": "USD"
                        },
                        {
                            "product_retailer_id": "nqryix03ez",
                            "quantity": 1,
                            "item_price": 25,
                            "currency": "USD"
                        }
                    ]
                }
            }
        ]
    }
}
Interactive 交互式消息
  • A WhatsApp user taps a row in an interactive list message.
  • A WhatsApp user taps a button in an interactive reply button message.
{
    "event": "new_message",
    "business_phone": "6281519236680",
    "message": {
        "messaging_product": "whatsapp",
        "metadata": {
            "display_phone_number": "15550783881",
            "phone_number_id": "106540352242922"
        },
        "contacts": [
            {
                "profile": {
                    "name": "Sheena Nelson"
                },
                "wa_id": "16505551234"
            }
        ],
        "messages": [
            {
                "context": {
                    "from": "15550783881",
                    "id": "wamid.HBgLMTQxMjU1NTA4MjkVAgASGBQzQUNCNjk5RDUwNUZGMUZEM0VBRAA="
                },
                "from": "16505551234",
                "id": "wamid.HBgLMTY1MDM4Nzk0MzkVAgASGBQzQUFERjg0NDEzNDdFODU3MUMxMAA=",
                "timestamp": "1749854575",
                "type": "interactive",
                "interactive": {
                    "type": "list_reply",
                    "list_reply": {
                        "id": "priority_express",
                        "title": "Priority Mail Express",
                        "description": "Next Day to 2 Days"
                    }
                }
            }
        ]
    }
}
Unsupported 不支持的消息类型
  • META API 不支持的消息类型
{
    "event": "new_message",
    "business_phone": "6281519236680",
    "message": {
        "messaging_product": "whatsapp",
        "metadata": {
            "display_phone_number": "6281519236680",
            "phone_number_id": "302702419599374"
        },
        "contacts": [
            {
                "profile": {
                    "name": "Lessie Laytoya"
                },
                "wa_id": "85268415026"
            }
        ],
        "messages": [
            {
                "from": "85268415026",
                "id": "wamid.HBgLODUyNjg0MTUwMjYVAgASGBQzQUQ1NzI3MTZFMDlBNEE0RkU4RQA=",
                "timestamp": "1756113604",
                "errors": [
                    {
                        "code": 131051,
                        "title": "Message type unknown",
                        "message": "Message type unknown",
                        "error_data": {
                            "details": "Message type is currently not supported."
                        }
                    }
                ],
                "type": "unsupported"
            }
        ]
    }
}