0

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!

  • I'm new to plivo and having some issues of my own, one thing I noticed is that my SMS are not showing up under logs -> SMS, but they are under logs -> debug. I know that doesn't answer your question, but hopefully it helps! – Ben Carlson Apr 30 '15 at 03:12

2 Answers2

1

I'm new as well and was having the exact problem as the poster above me. I was looking through their documentation and i found this:

"Note: If you are using a Plivo Trial account for this example, you can only send sms to phone numbers that have been verified with Plivo. Phone numbers can be verified at the Sandbox Numbers page."

Once i added my phone number, it worked.

One more thing: when i filled out the form to verify the number, i noticed it would not validate with [area code]number. The other thing i made sure i did was send the number in the format [CountryCode][Area Code] Number

muckeypuck
  • 52
  • 7
0

My experience.

I bought a Plivo US number. I setup the Application with "Message URL" but my server was never hit when I tried to send an SMS from an IT or a UK number.

I tried to call using the UK number and I found the log for missing "Hangup URL" in SMS/Logs/Debug. With the helpdesk we tried to send SMS from a US numbers. It works. I haven't read about any limitation for the SMS source country and also the help desk didn't says nothing about it in the ticket (I explained everything precisely).

So, that's it. A US number cannot receive SMS from a non-US number. (but apparently calls work). I also tried to receive a verification code from PayPal US and this does not work too. The help desk guy suggested me to buy a UK number for SMS from UK, but they don't sell UK numbers if you select "SMS"!

Alex 75
  • 2,798
  • 1
  • 31
  • 48