-
Notifications
You must be signed in to change notification settings - Fork 56
/
record-a-call.py
executable file
·42 lines (35 loc) · 1019 Bytes
/
record-a-call.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
from pprint import pprint
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route("/webhooks/answer")
def answer_call():
ncco = [
{
"action": "talk",
"text": "Hi, we will shortly forward your call. This call is recorded for quality assurance purposes."
},
{
"action": "record",
"eventUrl": ["https://demo.ngrok.io/webhooks/recordings"]
},
{
"action": "connect",
"eventUrl": ["https://demo.ngrok.io/webhooks/event"],
"from": "VONAGE_NUMBER",
"endpoint": [
{
"type": "phone",
"number": "RECIPIENT_NUMBER"
}
]
}
]
return jsonify(ncco)
@app.route("/webhooks/recordings", methods=['POST'])
def recordings():
data = request.get_json()
pprint(data)
return "webhook received"
if __name__ == '__main__':
app.run(port=3000)