Skip to content

Commit

Permalink
add mark_as_read
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
filipporomani authored Jan 11, 2023
1 parent b933f95 commit 8a98518
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions heyoo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 8a98518

Please sign in to comment.