Skip to content

Instantly share code, notes, and snippets.

@t9toqwerty
Created August 30, 2018 21:32
Show Gist options
  • Save t9toqwerty/cb7bf0e8e9e742c40786939b4c204ec3 to your computer and use it in GitHub Desktop.
Save t9toqwerty/cb7bf0e8e9e742c40786939b4c204ec3 to your computer and use it in GitHub Desktop.
Example Dialogflow V2 Fullfillment Responder - Python Flask
import json
from flask import Flask, request, make_response
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
def makeWebhookResult(req):
if req.get("queryResult").get("action") != "interest":
return {}
else:
bankName = req.get("queryResult").get("parameters").get("BanksName")
interestRate = range
return {
"fulfillmentText": bankName + " interest rate is 5%",
}
@app.route('/webhook', methods=['POST'])
def handle_webhook():
req = request.get_json(silent=True, force=True)
res = makeWebhookResult(req)
res = make_response(json.dumps(res, indent=4))
res.headers['Content-Type'] = 'application/json'
return res
if __name__ == '__main__':
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment