-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
117 lines (91 loc) · 5.62 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from flask import Flask, request, Response
from send_sms import SMSClient
app = Flask(__name__)
@app.route('/initiate_call', methods=['GET', 'POST'])
def initate_call():
session_id = request.form.get('sessionId')
is_active = request.form.get('isActive')
if is_active == '1':
response = '<?xml version="1.0" encoding="UTF-8"?>'
response += '<Response>'
response += '<GetDigits timeout="30" finishOnKey="#" callbackUrl="https://zabi-voice.onrender.com/processed_to_next">'
response += '<Say>Welcome to Ziba. We offer personal training for tech courses for free and welcome voluteers to train newbees. Press 1 if you need access to tech free tech resource. pressed 2 to guide you if you are someone to guide you in your tech journey or press 3 to become a voluteer. After the number follow it with a hash sign</Say>'
response += '</GetDigits>'
response += '</Response>'
return Response(response, content_type='application/xml')
@app.route('/processed_to_next', methods=['GET', 'POST'])
def connect_to_expert():
session_id = request.form.get('sessionId')
dtmfDigits = request.form.get('dtmfDigits')
is_active = request.form.get('isActive')
if is_active == '1':
if dtmfDigits == '1':
response = '<?xml version="1.0" encoding="UTF-8"?>'
response += '<Response>'
response += '<GetDigits timeout="30" finishOnKey="#" callbackUrl="https://zabi-voice.onrender.com/access_to_material">'
response += '<Say>We offer reading tech material for frontend developers, backend developer, machine learning and cloud. Press 1 if you need access to tech materail in frontend, press 2 if you need access to tech materail in backend, press 3 if you need access to tech materail in machine learning and press 3 if you need access to tech materail in cloud. After the number follow it with a hash sign</Say>'
response += '</GetDigits>'
response += '</Response>'
return Response(response, content_type='application/xml')
elif dtmfDigits == '2':
response = '<?xml version="1.0" encoding="UTF-8"?>'
response += '<Response>'
response += '<Dial phoneNumbers="+254711959117" />'
response += '</Response>'
return Response(response, content_type='application/xml')
elif dtmfDigits == '3':
response = '<?xml version="1.0" encoding="UTF-8"?>'
response += '<Response>'
response += '<Dial phoneNumbers="+254769339499" />'
response += '</Response>'
return Response(response, content_type='application/xml')
@app.route('/access_to_material', methods=['GET', 'POST'])
def access_to_material():
session_id = request.form.get('sessionId')
dtmfDigits = request.form.get('dtmfDigits')
is_active = request.form.get('isActive')
callerNumber = request.form.get('callerNumber')
if is_active == '1':
if dtmfDigits == '1':
link = "https://medium.com/@simongideon918/upscaling-your-github-commit-messages-d360f94843"
message =f"We have sent you the link to our resource on frontend. Click the link attach {link}"
sms_client = SMSClient(callerNumber, message)
sms_client.send_sms()
response = '<?xml version="1.0" encoding="UTF-8"?>'
response += '<Response>'
response += '<Say>Check your inbox a link to the resource has been sent to you</Say>'
response += '</Response>'
return Response(response, content_type='application/xml')
elif dtmfDigits == '2':
link = "https://medium.com/@simongideon918/upscaling-your-github-commit-messages-d360f94843"
message =f"We have sent you the link to our resource on backend. Click the link attach {link}"
sms_client = SMSClient(callerNumber, message)
sms_client.send_sms()
response = '<?xml version="1.0" encoding="UTF-8"?>'
response += '<Response>'
response += '<Say>Check your inbox a link to the resource has been sent to you</Say>'
response += '</Response>'
return Response(response, content_type='application/xml')
elif dtmfDigits == '3':
link = "https://medium.com/@simongideon918/upscaling-your-github-commit-messages-d360f94843"
message =f"We have sent you the link to our resource on machine learning. Click the link attach {link}"
sms_client = SMSClient(callerNumber, message)
sms_client.send_sms()
response = '<?xml version="1.0" encoding="UTF-8"?>'
response += '<Response>'
response += '<Say>Check your inbox a link to the resource has been sent to you</Say>'
response += '</Response>'
return Response(response, content_type='application/xml')
elif dtmfDigits == '4':
link = "https://medium.com/@simongideon918/upscaling-your-github-commit-messages-d360f94843"
message =f"We have sent you the link to our resource on cloud. Click the link attach {link}"
sms_client = SMSClient(callerNumber, message)
sms_client.send_sms()
response = '<?xml version="1.0" encoding="UTF-8"?>'
response += '<Response>'
response += '<Say>Check your inbox a link to the resource has been sent to you</Say>'
response += '</Response>'
return Response(response, content_type='application/xml')
# ===============================================================================================
if __name__ == '__main__':
app.run(debug=True)