Last active
January 10, 2019 10:19
-
-
Save Gaikanomer9/392cbdd14f213a052d765a248a844854 to your computer and use it in GitHub Desktop.
Sample Flask app for webhook handling at Dialogflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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