Use webhooks to be notified about new message, ack or chat update that happen in a instance_whatsapp.
You can set a http or https url and Mercury can sends the Event object, via an HTTP POST request, to any endpoint URLs that you have defined in your account’s Webhooks settings The webhook event object have this structure:
{"type":"ack","data":{...},"time":1559062461,"instance_number":"11223"}
fields | type | description |
type | string | type of event. Can have the following values :
|
data | object | Can have the following values :
|
time | number | is the unix timestamp in seconds when the event has been generated |
instance_number | string | (like instance_whatsapp.instance_number) is the instance whatsapp which generated the event |
{"type":"chatUpdate","data":{"_id":"5cebb9eb9ce23ae3e3c00510","instance_number":"43279","last_message_time":1558619725,"last_message_number":110,"last_message_number_id":"5cebb9eb9ce23ae3e3c004d9","count_message_read":0,"chatId":"4433223322-1554893669@g.us","name":"Group","image":"https://storage.googleapis.com/393245903518/59625670_473608333182253_8099661519656058880_n.jpg","metadata":{"isGroup":true,"participants":["445544333222@c.us","393519149609@c.us","393245903518@c.us"],"groupInviteLink":"https://chat.whatsapp.com/FeUFQQX23BiJVZONzVAQIu"}},"time":1559055235,"instance_number":"43279"}
{"type":"message","data":{"_id":"5cece1ef9ce23ae3e3cc001d","message_id":"false_4437367744@c.us_3AB22E9A006308D9A806","istance_number":"43279","body":"https://storage.googleapis.com/393245903518/2019%252F5%252F28%252F06a6a304-bade-47f8-ad35-a14a90006dfc.jpeg","body_translate":null,"type":"image","senderName":"george","fromMe":false,"author":"44575647748@c.us","time":1559028200,"chatId":"44575647748@c.us","messageNumber":198,"queueNumber":11,"status_queued":true,"status_queued_time":1559575922,"status_sent":null,"status_sent_time":null,"status_delivered":null,"status_delivered_time":null,"status_viewed":null,"status_viewed_time":null},"time":1559055235,"instance_number":"43279"}
{"type":"ack","data":{"_id":"5cece1ef9ce23ae3e3cc001d","message_id":"false_4437367744@c.us_3AB22E9A006308D9A806","istance_number":"43279","body":"https://storage.googleapis.com/393245903518/2019%252F5%252F28%252F06a6a304-bade-47f8-ad35-a14a90006dfc.jpeg","body_translate":null,"type":"image","senderName":"george","fromMe":false,"author":"44575647748@c.us","time":1559028200,"chatId":"44575647748@c.us","messageNumber":198,"queueNumber":11,"status_queued":true,"status_queued_time":1559575922,"status_sent":true,"status_sent_time":1559575925,"status_delivered":null,"status_delivered_time":null,"status_viewed":null,"status_viewed_time":null},"time":1559055235,"instance_number":"43279"}
​