I want to send a customized message and/or a document to a list of people everyday using the Whatsapp API.
This is the code I use
import requests
import json
import time
url = f"https://graph.facebook.com/v17.0/{ID}/messages"
payload = json.dumps({
"messaging_product": "whatsapp",
"to": person,
"type": "document",
"document": {"id":media_id,
"filename": file_name}
})
headers = {
'Authorization': 'Bearer {TOKEN}',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
The problem is these messages aren't being delivered. But I understand that there has to be reply from the user initially, for the conversation to continue and for the above defined code to work properly.
The issue here is that there is a 24 hour validity for the conversation,and since I want to send these messages everyday I must get a user reply every day and only then can I send out these messages. Is there a way I can keep sending the messages to the particular user without them replying back every 24 hours or if they reply back to an initial message, they can keep receiving messages indefinitely.
I can't use predefined templates also because as of now only pdf files can be sent in template messages whereas I would need to send pdf,pptx,csv and excel files.