Skip to content

Commit d5c0adf

Browse files
author
Tony Bedford
committed
Another building block plus fixes.
1 parent 4fbaa42 commit d5c0adf

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env python3
2+
from flask import Flask, request, jsonify
3+
from pprint import pprint
4+
5+
app = Flask(__name__)
6+
7+
@app.route("/webhooks/answer")
8+
def answer_call():
9+
ncco = [
10+
{
11+
"action": "talk",
12+
"text": "Hi, we will shortly forward your call. This call is recorded for quality assurance purposes."
13+
},
14+
{
15+
"action": "record",
16+
"split" : "conversation",
17+
"eventUrl": ["https://demo.ngrok.io/webhooks/recordings"]
18+
},
19+
{
20+
"action": "connect",
21+
"eventUrl": ["https://demo.ngrok.io/webhooks/event"],
22+
"from": "NEXMO_NUMBER",
23+
"endpoint": [
24+
{
25+
"type": "phone",
26+
"number": "RECIPIENT_NUMBER"
27+
}
28+
]
29+
}
30+
]
31+
return jsonify(ncco)
32+
33+
@app.route("/webhooks/recordings", methods=['POST'])
34+
def recordings():
35+
36+
data = request.get_json()
37+
pprint(data)
38+
39+
if __name__ == '__main__':
40+
app.run(port=3000)

voice/record-a-call.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ def answer_call():
1313
},
1414
{
1515
"action": "record",
16-
"eventUrl": ["https://275d6df0.ngrok.io/webhooks/recordings"]
16+
"eventUrl": ["https://demo.ngrok.io/webhooks/recordings"]
1717
},
1818
{
1919
"action": "connect",
20-
"eventUrl": ["https://275d6df0.ngrok.io/webhooks/event"],
20+
"eventUrl": ["https://demo.ngrok.io/webhooks/event"],
2121
"from": "NEXMO_NUMBER",
2222
"endpoint": [
2323
{
@@ -35,8 +35,5 @@ def recordings():
3535
data = request.get_json()
3636
pprint(data)
3737

38-
recording_url = request.args['recording_url']
39-
pprint(recording_url)
40-
4138
if __name__ == '__main__':
4239
app.run(port=3000)

0 commit comments

Comments
 (0)