URL changed in sms sent by Twilio - url

URL we send in message is like “tinyurl.com/abcceb8w” but when received by user in sms extra sign "#" is appended at end like “tinyurl.com/abcceb8w#” , which makes the URL invalid.
Issue is occurring for Canadian numbers. Works fine for USA and other countries.
What is possible reason for the issue and what is its fix?

First, never use public URL shorteners in SMS messages, it will dramatically increase the chances of your message being blocked by carriers.
Second, open a ticket with Twilio support (via the Twilio Console, upper right hand side, under the ?, Submit a Ticket), as the can investigate what happened.

Related

Paste outbound phone number in the SMS body

I wanted to paste in our customer phone number to a URL as value so we can send them another message after based on their posted review. We're basically going to send them a thank you sms if they posted a thumbs up. If posted a thumbs down, we're going to send them our info on where to forward their concerns. This doesn't seem to work:
The sms received only has https://review.com/review/google-los-angeles/?p=
without the phone number rendered.
I think I got it. It should be {{contact.channel.address}}

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.

Twilio inbound messages - Not Shown

I'm having a problem receiving Messages and i don't know where and what goes wrong.
Right now i received messages from the United States that are shown in the Inbound Twilio Dashboard and are accessible through the API.
e.g.:
<% #client.account.sms.messages.list({ from: "#{#contact.mobile}", }).each do |message| %>
Bur responses from other countries don't show up anywhere.
For Sending and receiving messages i use the format:
+1757*******
Has the format something to do with it ? What am i missing?
From Twilio Doc:
Phone numbers should be formatted with a '+' and country code e.g.,
+16175551212 (E.164 format). For 'to' numbers without a '+', Twilio will use the same country code as the 'from' number. Twilio will also
attempt to handle locally formatted numbers for that country code
(e.g. (415) 555-1212 for US, 07400123456 for GB). If you are sending
to a different country than the 'from' number, you must include a '+'
and the country code to ensure proper delivery.
After some serious Twilio Scanning i found the Answer - Read below
Twilio Evangelist here.
This could be a number of things. So first off, do the incoming messages show in your Message Logs on the Twilio Dashboard?
If they don't show up, then you make sure you have a URL set for number receiving them.
If they do show up, copy one of the numbers as shown in the logs and try this out in your app. It's a little tricky to be specific without more details, but I expect you should use the +<country><number> format as stated. So for US: +1415xxxx..., for the UK +447590xxxx...' and so on.
You could also try running this code:
<% #client.account.messages.list({to: your_twilio_number}).each do |message| %>
Display all the messages and check for the inbound messages there, then try again once you've double checked your contact.mobile formatting.
Hope this helps.
For everyone with the Same Issue.
When Setting up a Twilio account you receive a US Number, which works a little different from other Countries.
SMS Enabled Phone Numbers: Some are able to send SMS internationally and domestically, but others are only able to send and receive SMS domestically.
For the United States there is no Mobile, only Toll-Free and Local. With that, other carriers (Outside the US) wont even let your sms trough, thinking that the number on the other end is not a Mobile.
Basically, only US Numbers can send an SMS to a US Number, other countries can't.
So i bought a UK Number and everything is working now.

Confusion with Moonshado Heroku Add-on

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)

Resources