From 8a985186fb648daff9945d45ba4cf703325ca5fc Mon Sep 17 00:00:00 2001 From: Filippo Romani Date: Wed, 11 Jan 2023 18:03:06 +0100 Subject: [PATCH] add mark_as_read Messages can now be marked as read by using the mark_as_read function. Required arguments: message_id, the id of the message to be marked as read Return: True or False depending on operation success. --- heyoo/__init__.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/heyoo/__init__.py b/heyoo/__init__.py index 47e2c55..b91578c 100644 --- a/heyoo/__init__.py +++ b/heyoo/__init__.py @@ -488,6 +488,27 @@ def delete_media(self, media_id: str): logging.info(f"Status code: {r.status_code}") logging.info(f"Response: {r.json()}") return None + + def mark_as_read(self, message_id: str): + """ + Marks a message as read + + Args: + message_id[str]: Id of the message to be marked as read + """ + headers = { + 'Authorization': f'Bearer {self.token}', + 'Content-Type': 'application/json', + } + + json_data = { + 'messaging_product': 'whatsapp', + 'status': 'read', + 'message_id': message_id, + } + response = requests.post( + f'https://graph.facebook.com/v15.0/{self.phone_number_id}/messages', headers=headers, json=json_data).json() + return response["success"] def create_button(self, button): """