Sending SMS text messages with webAPI - my experience

So, I thought I could just use a JSON post or a GET to send a text message.   Well, if it was that easy, there would be security problems with hackers using your api token ...  So, the way to do it is basically by a 2 step process:

1.   You send a GET having your parameter names and Tropos params:

       GET   api.tropo.com/1.0/sessions  with Tropos params:

  • action = 'create'
  • token = '43..f8'   ( which is your apps token )

as well as WHATEVER your want to use for variable names

  • myMsg = 'Hey Jude'
  • myFriendsNum = '+15556667777'

so it is a GET with 4 URL parameters.   (   I think you can also do a JSON POST with a stringified object ).

2.  Have your webpage ready for Tropo to POST to it -- very quickly.   Your webpage will deserialize the JSON to yourObj.   Look for yourObj.session.parameters.   It will have myMsg and myFriendsNum. So, maybe assign

  • myM = yourObj.session.parameters.myMsg
  • myN = yourObj.session.parameters.myFriendsNum

Then, construct a data structure ( or hardcode the JSON string ) and serialize into a JSON string to output (or render) so that Tropo sees as a response something like:

  "tropo": [
      "message": {
        "channel": "TEXT",
        "name": "enum170320908",
        "network": "SMS",
        "to": "+15556667777",
        "say": {
          "value": "Hey Jude"

Note that "say" can be an object or an array. Also, name can be anything I guess ... I just made a method to generate something.

BTW, you need to get the guys at tropo to clear your app to send SMS messages.    They ask you to do a quick process to verify your account, etc.



Please sign in to leave a comment.