Skip to content

Instantly share code, notes, and snippets.

@Gaikanomer9
Last active January 10, 2019 10:19
Show Gist options
  • Save Gaikanomer9/392cbdd14f213a052d765a248a844854 to your computer and use it in GitHub Desktop.
Save Gaikanomer9/392cbdd14f213a052d765a248a844854 to your computer and use it in GitHub Desktop.
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