-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathpython-flask-ivr.py
More file actions
33 lines (29 loc) · 901 Bytes
/
python-flask-ivr.py
File metadata and controls
33 lines (29 loc) · 901 Bytes
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
import json
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route("/incomingCalls", methods=['GET','POST'])
def home():
print(request.form)
response = {
"ivr": "https://46elks.com/static/sound/ivr-menu.mp3",
"digits": 1,
"skippable":True,
"next":"https://yourapp.example/elks/ivr"
}
return json.dumps(response)
@app.route("/ivr", methods=['POST'])
def calls_in():
print(request.form)
if request.form['result'] == "1":
voice_start = {
'play': "https://www.46elks.com/static/sound/voiceinfo.mp3"
}
return json.dumps(voice_start)
elif request.form['result'] == "2":
voice_start = {
'play': "https://www.46elks.com/static/sound/smsinfo.mp3",
}
return json.dumps(voice_start)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000)