Sample Flask app for webhook handling at Dialogflow
# -*- coding: utf-8 -*- | |
from flask import Flask, request, make_response, jsonify | |
app = Flask(__name__) | |
@app.route('/webhook', methods=['POST']) | |
def webhook(): | |
req = request.get_json(force=True) | |
intent = req.get('queryResult').get('intent').get('displayName') | |
print(intent) | |
if intent == 'Sample intent': | |
res = make_response(jsonify( | |
{ | |
"fulfillmentText": "Привет от сервера!", | |
} | |
)) | |
return res | |
return make_response(jsonify( | |
{ | |
"fulfillmentText": "Совпадений намерений не найдено!", | |
} | |
)) | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0', debug=True, port=5000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment