One of the most common use cases for Tropo is for sending an SMS from another app, be it a web application or a mobile app. With Tropo Scripting and the Tropo API, you can easily trigger outbound SMS messages from a simple HTTP GET using your application’s API key and pointing it to Tropo, for example:
You’ll notice that there are a few variables included in that GET string, “myAPIkey”, “myString” and “myNumber”, along with an “action”.
The “action=create” tells Tropo that you would like to create a new session. The “myAPIkey” tells Tropo which application to run. But Tropo doesn’t natively know what to do with those other variables. This is where Tropo Scripting comes to play.
Before any of this will work, you need to create a new Tropo Scripting app in you Tropo account. Follow these steps:
1) Log into your Tropo account
2) Under “My Apps” select “Create new application”
3) Fill in the name of the application, something like “Super Simple SMS” works nicely.
4) Under Type of Application, choose “Scripting API” and click the “New Script” link. This will bring up the script editor.
6) Remember to include a filename (no spaces) with the correct extension for the language you chose, (.rb .php .js .py or .groovy) and then save the file.
7) Go all the way down to the bottom and click the “Finish” button.
Now that you’ve created your Tropo Scripting app, you’ll want to make sure that you have a couple of other things in place. One common problem is that you don’t have outbound SMS enabled for your account. For security reasons, when you create a new Tropo developer account, outbound SMS is disabled by default. To enable it, you must contact our support team, and they will be happy to assist you.
Also, in order to send SMS, you must have at least one U.S. or Canadian phone number attached to your application. This number will appear as the Caller ID when the number receives the message.
One other pro-tip: be patient, when you create a new application, add/remove a number or API key, it takes about 15 minutes for that change to propagate through the Tropo network, so go get a tasty beverage before testing your app.
If you look at your application, scroll all the way down to the bottom and you will see your API keys for Voice and Messaging. Copy the Messaging API key and paste it into the URL I posted above, replacing the “myAPIkey” variable. Find the phone number assigned to your app and replace the one in your script with the U.S. or Canadian number you assigned to your application.
Then simply replace “myNumber” with a mobile number you have nearby and test it out!
Happy coding 🙂