Skip to content

Commit f19c993

Browse files
Tony BedfordMark Lewin
Tony Bedford
authored and
Mark Lewin
committed
Add track NCCO code snippet (#62)
1 parent 9450588 commit f19c993

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

voice/track-ncco.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from flask import Flask, request, jsonify
2+
3+
app = Flask(__name__)
4+
5+
@app.route("/webhooks/answer")
6+
def answer_call():
7+
ncco = [{
8+
"action": "talk",
9+
"text": "Thanks for calling the notification line"
10+
},
11+
{
12+
"action": "notify",
13+
"payload": {
14+
"foo": "bar"
15+
},
16+
"eventUrl": [
17+
"{url_root}webhooks/notification".format(url_root=request.url_root)
18+
]
19+
},
20+
{
21+
"action": "talk",
22+
"text": "You will never hear me as the notification URL will return an NCCO "
23+
}]
24+
return jsonify(ncco)
25+
26+
@app.route("/webhooks/notification", methods=['POST'])
27+
def notification():
28+
ncco = [{
29+
"action": "talk",
30+
"text": "Your notification has been received, loud and clear"
31+
}]
32+
return jsonify(ncco)
33+
34+
@app.route("/webhooks/event", methods=['POST'])
35+
def event():
36+
return "OK"
37+
38+
if __name__ == '__main__':
39+
app.run(host="localhost", port=3000)

0 commit comments

Comments
 (0)