-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
39 lines (30 loc) · 1015 Bytes
/
Copy pathapp.py
File metadata and controls
39 lines (30 loc) · 1015 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
34
35
36
37
38
39
from flask import Flask, request
from twilio.twiml.messaging_response import MessagingResponse
from utils import fetch_reply
app = Flask(__name__)
@app.route("/",methods=['POST'])
def hello():
resp = MessagingResponse()
response = detect_intent_from_text("hi", 12314)
resp.message(response.fulfillment_text)
return str(resp)
@app.route("/sms", methods=['POST'])
def sms_reply():
# Fetch the message
#print(request.form)
msg = request.form.get('Body')
sender=request.form.get('From')
# Create reply
resp = MessagingResponse()
#resp.message("You said: {}".format(msg))
#resp.message("You said: {}".format(msg)).media("https://images.unsplash.com/photo-1518791841217-8f162f1e1131?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80")
x,y=fetch_reply(msg,sender)
if y=="number":
resp.message(x)
elif y=="images":
resp.message("Your image").media(x)
else:
resp.message(x)
return str(resp)
if __name__ == "__main__":
app.run(debug=True)