From bd7f8868c1e708749f25a96332da702731ff0e2d Mon Sep 17 00:00:00 2001 From: Tony Bedford Date: Wed, 13 Nov 2019 18:21:16 +0000 Subject: [PATCH] Add track NCCO code snippet --- voice/track-ncco.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 voice/track-ncco.py diff --git a/voice/track-ncco.py b/voice/track-ncco.py new file mode 100644 index 0000000..de3fa5e --- /dev/null +++ b/voice/track-ncco.py @@ -0,0 +1,39 @@ +from flask import Flask, request, jsonify + +app = Flask(__name__) + +@app.route("/webhooks/answer") +def answer_call(): + ncco = [{ + "action": "talk", + "text": "Thanks for calling the notification line" + }, + { + "action": "notify", + "payload": { + "foo": "bar" + }, + "eventUrl": [ + "{url_root}webhooks/notification".format(url_root=request.url_root) + ] + }, + { + "action": "talk", + "text": "You will never hear me as the notification URL will return an NCCO " + }] + return jsonify(ncco) + +@app.route("/webhooks/notification", methods=['POST']) +def notification(): + ncco = [{ + "action": "talk", + "text": "Your notification has been received, loud and clear" + }] + return jsonify(ncco) + +@app.route("/webhooks/event", methods=['POST']) +def event(): + return "OK" + +if __name__ == '__main__': + app.run(host="localhost", port=3000)