How to get a notification that an incoming message has been read from the phone#
In order to receive notifications that an incoming message has been read on a linked device, you need to use the following algorithm.
Contents
- Set the required settings on the instance
- How to view the read notification in webhooks and journals
1. Set the required settings on the instance#
-
Disable the
markIncomingMessagesReadedsetting with the SetSettings method by specifying the valuenoin themarkIncomingMessagesReadedfield, or in your personal account in the instance settings you need to set the Mark incoming messages as read fieldto the No position -
Enable the
incomingWebhookandincomingMessageStatusWebhooksettings with the SetSettings method or in your personal account in the instance settings.
2. How to view the read notification in webhooks and journals#
Required settings and limitations
Make sure that all the settings specified in point 1 have been applied.
No more than 100 incoming messages can be read per call. If there are more unread messages, the method has to be executed several times.
The unreadCount field has been added to the response of the getChats method, which shows the number of unread messages in the chat.
When using the readChat method, the messages are marked as read in the journal. If idMessage is not specified, all the messages of the chat are read. If idMessage is specified, the messages are read up to and including the specified message.
An example of an incoming notification#
{
"typeWebhook": "incomingMessageStatus",
"chatId": "79876543210@c.us",
"instanceData": {
"idInstance": 1234,
"wid": "79876543210@c.us",
"typeInstance": "whatsapp"
},
"timestamp": 1586700802, // the time the message was read
"idMessage": "BAE550673B9C04973",
"status": "read", // The message has been read
"sendByApi": false
}
An example of an incoming journal#
{
"type": "incoming",
"idMessage": "BAE550673B9C04973",
"timestamp": 1713332139,
"typeMessage": "textMessage",
"chatId": "79876543210@c.us",
"textMessage": "I use GREEN-API.",
"senderId": "79876543210@c.uss",
"senderName": "Ivan Tsarevich",
"senderContactName": "Ivan Tsarevich",
"isRead": true, // the message has been read
"isReadTimestamp": 1713332139
},
{
"type": "incoming",
"idMessage": "BAE550673B9C04973",
"timestamp": 1713332139,
"typeMessage": "textMessage",
"chatId": "79876543210@c.us",
"textMessage": "I use GREEN-API.",
"senderId": "79876543210@c.uss",
"senderName": "Ivan Tsarevich",
"senderContactName": "Ivan Tsarevich",
"isRead": false // the message has not been read
}