-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
32 lines (26 loc) · 958 Bytes
/
app.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
from flask import Flask, Response, request
from twilio.twiml.voice_response import Dial, Gather, VoiceResponse
app = Flask(__name__)
@app.route("/conference", methods=["POST"])
def conference():
print(f"{request.form=}")
response = VoiceResponse()
pin_code = request.form.get("Digits")
if pin_code and pin_code == "12345":
dial = Dial()
dial.conference(
"Twilio Test Conference",
status_callback="/events",
status_callback_event="start end join leave mute hold",
)
response.append(dial)
else:
gather = Gather(action="/conference")
gather.say("Please enter your conference pin,\nfollowed by the pound sign")
response.append(gather)
return Response(str(response), mimetype="text/xml")
@app.route("/events", methods=["POST"])
def events():
for key, value in request.form.items():
print(f"{key=} - {value=}")
return "", 200