I've just started using Plivo to set up an sms service. I'm trying to receive SMSs on my server but my server just doesn't seem to receive them.
I've set it up on heroku, the below is my code: import plivo, plivoxml import os import os.path from flask import Flask, request
app = Flask(__name__)
@app.route("/receive-sms/",methods=['GET','POST'])
def inbound_sms():
# Sender's phone number
from_number = request.values.get('From')
print from_number
# Receiver's phone number - Plivo number
to_number = request.values.get('To')
# The text which was received
text = request.values.get('Text')
params = {
"src": to_number,
"dst": from_number,
}
body = "Thanks, we've received your message."
# Generate a Message XML with the details of
# the reply to be sent.
r = plivoxml.Response()
r.addMessage(body, **params)
return r.to_xml()
if __name__ == "__main__":
port = int(os.environ.get('PORT', 5000))
# print port
app.run(host='0.0.0.0', port=port)
On Plivo, my message url is: http://ripmac.herokuapp.com/receive-sms/
I've linked my Plivo number to the right plivo application.
Additionally, I'm not sure if I'm supposed to see messages when I login on Plivo and navigate to the logs->SMS. There are no logs which is starting to make me think that there is something wrong with the port/message url. Any help will be much appreciated. Thanks!