I tried to deployed a chatbot which involves the application of MongoDB but I am stuck by this bug all day (figure 1). I cannot what is wrong because I follow the doc strictly and check the config vars over and over again to make sure all of them are correct. Can anyone give me some suggestions? I just ran out of options. Here is a snippet of codes:
ACCESS_TOKEN = os.environ['ACCESS_TOKEN']
VERIFY_TOKEN = os.environ['VERIFY_TOKEN']
MONGODB_URI = os.environ['MONGODB_URI']
db = MongoClient(MONGODB_URI).get_database()
collection = db.get_collection('QnA')
time = datetime.fromtimestamp(int(str(message['timestamp'])[:-3])).strftime(
'%Y-%m-%d %H:%M:%S')
collection.insert_one({"question": message['message'].get('text'),
"answer": response, 'time': time})
It turned out to be just a stupid question because of my carelessness. The data is not authenticated to be inserted until I add the IP of facebook messenger into the whitelist of my project. This can be referred to this link.