0

I have successfully created a facebook messenger bot using Graph API by following these two tutorials: https://www.pragnakalp.com/create-facebook-chatbot-using-python-tutorial-with-examples/

https://www.pragnakalp.com/build-an-automated-ai-powered-facebook-messenger-chatbot-with-chatgpt-using-flask/

The bot works great when I open the page messenger and have a talk with it. But it does not cater anyone other than me. I have also made the application live. I am new to this that's why I cannot really figure out the problem here. What steps am I missing? Why can't it reply to anyone else? This is my code

PAGE_ACCESS_TOKEN='EAAO------'
API = "https://graph.facebook.com/v17.0/me/messages?access_token="+PAGE_ACCESS_TOKEN

@app.route("/", methods=['GET'])
def fbverify():
    if request.args.get("hub.mode") == "subscribe" and request.args.get("hub.challenge"):
        if not request.args.get("hub.verify_token")==PAGE_ACCESS_TOKEN:
            return "Verification token missmatch", 403
        return request.args['hub.challenge'], 200
    return "Hello", 200


@app.route("/", methods=['POST'])
def fbwebhook():
    data = request.get_json()
    print(data)
    
        # Read messages from facebook messenger.
    message = data['entry'][0]['messaging'][0]['message']
    print(message)
    sender_id = data['entry'][0]['messaging'][0]['sender']['id']
    print(sender_id)
    if message['text']:
        # Response from chatbot_handler
        response_text = chatbot_handler(message['text'], chat_history)  
        
        request_body = {
            "recipient": {
                "id": sender_id
            },
            "message": {
                "text": response_text  # Use the response from chatbot_handler
            }
        }
        
        response = requests.post(API, json=request_body).json()
        return response

Any kind of help will be highly appreciated. Thanks!

3
  • 1
    Did you also submit your app for review, of all the permissions it requests and features it uses? Commented Aug 22, 2023 at 6:07
  • No. How can I do that? Thanks! Commented Aug 22, 2023 at 10:51
  • 1
    developers.facebook.com/docs/app-review Commented Aug 22, 2023 at 10:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.