I’m trying to make a simple ChatBot App that replies from my page to anyone who messages it. Everything is built using Python, Flask. Able to retrieve messages via Webhook, and then send messages using the Graph API
Here’s a sample code and function I use to send messages using my page:
def send_message_to_fb_messenger(recipient_id: str, message_text: str) -> None:
retry_attempt = retry
url = f"https://graph.facebook.com/v19.0/me/messages?access_token={FB_PAGE_ACCESS_TOKEN}"
data = {
"recipient": {"id": recipient_id},
"message": {"text": message_text}
}
response = requests.post(url, json=data)
if response.status_code == 200:
print("[LOGS] Message sent successfully.")
The ChatBot works great, it responds to everyone quickly (it’s responding to other users as well even though pages_messaging isn’t even approved yet for some reason).
However, when we try to submit an App review, it gets rejected and fails because the bot/script was not able to reply at all. I kept testing and tried different ways to make the bot faster on the server side but it still wasn’t replying on my second attempt. I’m not getting any error message in my logs as well. There’s no other issue with the Chatbot at all, it’s able to reply to me and my friends quickly.
Is there any way to resolve this? Or is there something wrong with my approach?