I'm trying to my app with DialogFlow fulfillment webhook but whenever I make a request it returns:
POST /webhook 500 INTERNAL SERVER ERROR
from ngrok. I have checked almost everything on dialogflow and ngrok connections and came to nothing
WebHook URL
https://3aa04ed7.ngrok.io/webhook
main.py
@app.route('/webhook', methods=['POST'])
def webhook():
req = request.get_json(silent=True, force=True)
print("Request:")
print(json.dumps(req, indent=4))
res = processRequest(req)
res = json.dumps(res, indent=4)
print("Response:")
print(res)
response = make_response(res)
response.headers['Content-Type'] = 'application/json'
return response
def processRequest(req):
print("Processing request")
result = req.get("result")
# contexts = result.get("contexts")
action = result.get("action")
if action == "givesymptoms":
return giveSymptoms(req)
elif action == "followup":
return followUp(req)
return result
Terminal Error
Processing request
127.0.0.1 - - [09/Dec/2019 04:56:40] "POST /webhook HTTP/1.1" 500 -
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\flask\app.py", line 2328, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Python27\lib\site-packages\flask\app.py", line 2314, in wsgi_app
response = self.handle_exception(e)
File "C:\Python27\lib\site-packages\flask\app.py", line 1760, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Python27\lib\site-packages\flask\app.py", line 2311, in wsgi_app
response = self.full_dispatch_request()
File "C:\Python27\lib\site-packages\flask\app.py", line 1834, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Python27\lib\site-packages\flask\app.py", line 1737, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Python27\lib\site-packages\flask\app.py", line 1832, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Python27\lib\site-packages\flask\app.py", line 1818, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\User\Desktop\HomeDoctor-master\HomeDoctor-master\main.py", line 41, in webhook
res = processRequest(req)
File "C:\Users\User\Desktop\HomeDoctor-master\HomeDoctor-master\main.py", line 56, in processRequest
action = result.get("action")
AttributeError: 'NoneType' object has no attribute 'get'