Confusion with Moonshado Heroku Add-on - ruby-on-rails

According to this documention, it seems as if Moonshado will automatically route any mobile-originated SMS message to your application if it contains the first word as your keyword. I do not understand how this is possible. Any SMS message in the US that contains the first word as your keyword will be routed to your app? How is it possible for Moonshado to read every message? There must be something I'm not getting.

For SMS messages originating in the US, any messages sent to 69940 containing your keyword as the first word, will be routed to your application.
So if you want your users to be able to send SMS messages to you application, you need to tell them to SMS your keyword to '69940'.
It mentions it very briefly at the bottom of the documentation:
Further reading:
US incoming SMS ShortCode is 69940 (International MO support coming soon)

Related

Apple messages auto-call

have an interesting problem I need to solve, I was hoping if anyone could give me some sort of an idea.
For example, if I get a text from someone saying (string) “URGENT” on my iPhone, I want to call them immediately.
So say I get a message, it could be any message but if their message says “urgent”, I need to call them ASAP, even when my phone is turned off.
Is there a way to do this, using API or anything?? I have no idea!!
Example say I get a messages saying:
Number 042XXXXX sends me a text:
"Hi Name, I have some urgent work for you"
Number 1300 XXX XXX sends me a text:
"Urgent help needed"
Both of these messages would be read by iPhone and their respective numbers would be dialled urgently.
Is there such a way to do this/automate this??
Any advice would be appreciated!!
I have no idea what to do, I am blank!!
I think the problem you have needs an indirect solution because, as Paulw11 points out, Apple don't allow you to inspect the message directly.
It would be possible to make use of Twilio's Programmable SMS API to setup a special phone number that customers could send text messages to. Then you use the APIs of Twilio to read the messages and then send an Apple Push Notification message for those the had "urgent" in the message.
You could then write an iOS app which receives push notification messages and takes the actions you desire. For example, it could present a screen which could automatically dial the number in question.

Twilio SMS - what am I doing wrong?

So, I have WHMCS setup to use Twilio with a new module, however, I have managed to get as far as setting it up and having SMS messages go out to customers in Australia as I have an AUS number connected to my Twilio account.
The issue is that when say for an example a US customer signs up the SMS fails and says "cannot send sms", the logs aren't helpful for this Twilio newb.
Here is the example:
The process of sending SMS to the user phone number (+1310xxxxxxx) from the summary page has failed - Twilio (company name)
If I was to send a message to say Spain it seems to work, which is odd enough.
I also tried on a +34 and it sent. Also seems to work on the UK +44.
I have GEO options setup to work as they should within Twilio, though, the error message does not appear on my Twilio logs, simply internal.
Here is the module log.
I have only edited the text out to give you what is showing.
Request:
Array
(
[To] => +1310xxxxxxx
[Body] => test
[From] => Company name
)
Response
The 'To' phone number: +1310xxxxxxx, is not currently reachable using the 'From' phone number: Company name via SMS.
So presently SMS messages to the USA do not work, I cannot speak for every other country out there though, what can I do here or how would I set my Twilio account correctly to ensure my SMS messages are being delivered?
Many thanks.
Twilio developer evangelist here.
From what you're saying I think you're sending messages using an alphanumeric sender ID rather than a phone number?
If that's the case then you are getting rejected from the US because the US telephone system doesn't accept alphanumeric sender IDs (neither do some other countries, just not the ones you've tested). You can see the countries that do and don't support alphanumeric sender IDs in this table in our documentation.
To fix this you'll need a number to send the messages from in the US, I'd recommend getting a new US number for this.
Then you can either catch the error and retry using the number in place of the sender ID.
Or, for a more resilient method, take a look into Twilio Messaging Services that can do automatic failover to a number when sending with alphanumeric senders.
Let me know if this helps at all.

Twilio Messaging - Correlating SID

We use twilio for sending message.
We are not sure how to correlate the response with the message we send. We might send multiple messages to the same Mobile. But, not sure how to correlate response with the messages we sent as the SID's are different.
Is there anyway to relate the response with the message.
Thanks
No, SMS doesn't work like that.
I you send me 5 text messages from your cellphone and then I reply to one you have no way of telling which one I'm replying to.
It's not a Twilio limitation, the SMS standard has no provision to track replies to individual messages
As an afterthought I came up with a hacky solution to this. It's a bit involved so I guess it depends how much you want the functionality.
This works for me using Chrome beta on Android 7.0, YMMV.
Create a php script with the following code and put it on your webserver:
<?php
// increase last digit as necessary to suit string length of your variable
$smsid = substr($_SERVER["QUERY_STRING"],0,1);
// Query database for SMS id, record timestamp of request, optionally return text to be included at the beginning of the SMS reply
$msg= urlencode($databaseResult);
// Remove <?body=$msg> if you just want the link to create a blank reply. Change the phone number to your incoming Twilio number.
header( "Location: sms:+1555444333?body=$msg" )
Now sign up for a URL shortening service which passes URL parameters and create a shortened URL which points to your php script. I used tr.im.
Depending upon your volume of SMS you will have to adjust the length of your variable, but unless you spam people to death I'm going to assume a single character will be enough to identify a unique text.
Using the example tr.im/SMS as your shortened url, you append a variable to the end like so tr.im/SMS?A and put the link in your outgoing SMS. When the user clicks the link your server redirect will open the SMS app on their phone and create a text to your number. If you have included the "?body=$msg" in your php above the new message will have your text at the start.
Personally I probably wouldn't bother adding text, they might delete it before they send it anyway and it's just likely to confuse people. If you log the request variables and timestamps to your database you should be able to tie them together with the phone number as most people will send you their reply within a couple of minutes of the server request. You can also increase the length of your custom URL variable if you struggle to correlate messages. Recycle variables once you have linked a reply etc...
Finally change your Twilio configuration so your outgoing SMS present the company name instead of your Twilio number as the sender. Users cannot directly reply to messages if the sender isn't a number, so they will have to use your link.
Generate a sequential identifier for each message and append it to your link. Save the identifier to your database along with the corresponding message Sid from Twilio and the number you sent it to so you can match them up later.
Append "Click tr.im/SMS?$ to reply" to outgoing SMS, where $ is your variable.
Profit.

How do I use Twilio to receive text messages from users and reply to that text with a message?

1.) User sends a text message to a designated Twilio phone number
2.) Application receives this message and parses it for actionable data
3.) Application replies to sender with a text message delivering the requested information
How the heck do I do this with rails?!
Assuming your business logic doesn't take that long to execute, it's pretty simple to process a text and send a response. Here are the core steps:
Grab the twilio-ruby helper library.
Point your SMS Url to the Rails controller/action you'd like to invoke
Process the incoming request & execute your business logic
Instead of returning HTML, return TwiML
Here's a link to a simple app that does just this:
https://github.com/crabasa/twilio-rails-demo
Update: I've written two detailed blog posts on integration Twilio into a Rails 4.x app: Part 1 and Part 2.

Text Messages & Ruby on Rails

Is there any way to use text messages to CRUD data in a Rails app? For instance, a user would send a text message to a specific number and the Rails app could use that data in any way. Just wondering if there's a solution out there.
Lots of web services exist to do this. Try out http://twilio.com/.
my name is Jarod and I work at Twilio.com. It would be very easy to build a Rails app that handles incoming SMS using the Twilio API. Here is a high-level overview of how it would work:
Sign up for twilio
Point your new Twilio number SMS Url to the Rails controller/action you'd like to invoke.
Process the incoming request and do something with the data.
Note: When Twilio makes the request to your Rails app it will pass helpful parameters with the request including:
From: The phone number that sent this message.
To: The phone number of the recipient.
Body: The text body of the message. Up to 1600 characters long.
NumMedia: The number of media items associated with your message
Some geographic data like City, State, etc.
Here is a simple Rails app that does just that.
Hope this helps!

Resources