Receive SMS on twillion phone number - sms

I have attached call back URL in the Twilio account with the Twilio phone number. But still i am not getting a hit on the call back URL when sending SMS to twilio number. There is no history in Twilio about the message received, though it is showing sent from my mobile phone.

I did a work around to recieve messages.
In a background thread, I am continuously listening to see if the 'number of messages' changed:
def newMsgCame(self,client,old_len):
new_len = len(client.messages.list(to="<my twilio number>"))
if(new_len > old_len):
return True,new_len
return False,new_len
If yes, then I return the latest message:
def getMsg(self,client):
messages = client.messages.list(to="<my twilio number>")
if (len(messages) != 0):
return messages[0].body
return ""
This might fail in many scenarios though.

Related

Twilio sending messages and receiving back in cell phone

I am using Twilio rest API for Php and want to create an application to send and receive text messages.
We have many senders and every one wants to send and receive their messages. And every one want to receive text messages on their cell phone.
Is it possible to send text message to some one and we get our reply to our cell phone?
I am new in tiwlio so please can you guide me the procedure of sending and receiving text messages.
I have implemented sending part and not getting how to receive messages back on cell phone if someone reply.
Thanks
Twilio developer evangelist here.
When someone replies with a message to a Twilio phone number, Twilio will take the message and send it to a URL you define as an HTTP request. You can then decide what to do with the message.
You can, for example, forward the message on to another number. There is a restriction here in that you cannot forward the message and make it appear to have come from the original sender, you have to set the caller ID as one of your Twilio numbers. You can include the original sending number as part of the message though.
To do this, you would need to respond to the HTTP request with some TwiML. This is a subset of XML that tells Twilio what to do with the message. To forward the message including the original sender number, you would use the <Message> TwiML element from PHP like this:
<?php
$from = $_REQUEST['From'];
$body = $_REQUEST['Body'];
$forwarding_number = "THE NUMBER TO FORWARD THE MESSAGE TO";
// we'll forward from the Twilio number that received the message
$caller_id = $_REQUEST['To'];
header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
<Message to="<?php echo $forwarding_number; ?>" from="<?php echo $caller_id; ?>">
Message from <?php echo $from; ?>: <?php echo $body; ?>
</Message>
</Response>
As I said though, there are limitations on this, the message will be sent to your users phone from your Twilio number. In reality, you likely want to be able to reply to the message again, so it's perhaps better to just send a notification to your users and build an application that can receive those messages and display them in a dashboard, using the API to respond to them.
I have started an example of this sort of app here on GitHub (it's built in Node.js, but might give you an idea).
Let me know if that helps at all.

Twilio SMS sent from +12345

I am sending SMS using Twilio Node (http://twilio.github.io/twilio-node/).
In the from field I've set the number that Twilio gave me, yet when I receive the SMS it shows as +1 (234) 5.
The only thing I can think of is that I am using the trial account, but their FAQ doesn't say anything about this...
https://www.twilio.com/help/faq/twilio-basics/how-does-twilios-free-trial-work
Code snippet:
// Require and initialize the Twilio module with your credentials
var client = require('twilio')('A-FAKE-8cc', 'b53090-FAKE-6808');
// Send an SMS message
client.sendSms({
to:'+' + to,
from: '+15734XXXXXX',
body: 'Your code is ' + code
}, function(err, responseData) {
if (err) {
console.log(err);
} else {
console.log(responseData.from);
console.log(responseData.body);
}
}
);
Here is another piece of info: my twilio number is in the US, while my destination is in Israel - does it matter? Also, when I verified my number I received the code from this +12345 as well.
Confirming my suspicion: I've just verified a US number this time, and it showed the correct number (both from my app and from twilio).
Hey to be very honest your location doesn't matter to have a call on the Twilio platform apart from that if you want to have an upgraded account i'll suggest you to apply for Github's student developer program you'll get 50$ from that and you can buy some virtual numbers from that.
And to successfully make calls i am linking a repository which will help you in sending messages as well as calls over the internet.Getting started with Twilio at MLH INIT

+CMS ERROR 41 on Telit Modem

I am a developer, working on "Telit" GE865-Quad using AT commands.
I am planning an application, witch sends SMS when certain condition occurs. When the application does not send SMS the modem is shut-down (Therefore every time I want to send SMS I have to turn on the modem). This application sends 3 SMS to different numbers one after the other.
The application is working just fine. The problem apear after a while (after sending certain amount of SMS), when I give the command to send SMS I get "+CMS ERROR 41" ("Temporary failure"). Once this message appear, every time I try to send SMS I get the same ERROR - It is like the SIM card is stuck. The only way I have found to get rid of this error is to enter the SIM card to my privet phone and send SMS.
I have spoken to "Telit" representative and he could not give a satisfying answer other then adding more delay between messages.
This is some of the relevant code :
(Turning on sequence) // From "Telit" GE865-Quad DataSheet
> #QSS: 3 //Before I start working with the modem i wait for this response with means the SIM is ready to use and the registration is to cellular network is complete*/
AT+CMGF=1 // Text Mode
OK
AT+CMGS=+xxxxxxxxxxxx // My number.
"This is the message i want to send" //Preparing the desired message require some coding But I think this is irrelevant to the subject.
//Delay for 3 secs//
And again : AT+CMGS=+xxxxxxxxxxxx // My number.
"This is the message I want to send"
//Delay for 3 secs//
(The same thing one more time)
The questions are:
Why does it happen, what am I doing wrong??
How can I unblock the SIM? What does the phone do so I can keep sending SMS?
The purpose is the keep sending SMS automatically.
This is the first time I publish a message in this website so if something is unclear please let me know. :)
Thanks for all the helpers.
Itay.
today i encountered this +CMS ERROR: 41 error, many times.
There was about 40 unread messages in the receiving modem.
After i deleted all received messages error disappeared.
I think may be operator is protecting customers from spam.
Dmitri
It is due Either SMS service on your SIM is not available or your SMS subscription is expired.

How to handle delivery report in GSM Modem?

i want to use GSM Modem in an application for some purpose.
what i want is handling SMS delivery report for list of sent sms.
GSM Modem inbox & outbox are limited to 15 items. every time i read the inbox the gsm modem return a list an clear the list.
how to check delivery status of sms that had been deleted from GSM Modem inbox ?
i need something unique that enables me to identify each message.
every time i read the inbox the gsm modem return a list an clear the list.
Messages that are stored in modem's memory will not be removed after you read them. You just read message with at+cmgl={message id in storage} command and then remove it using at+cmgd={message id in storage} command (or not, as you wish. You can clear all modem's storages using at+cmgd=1,4 command).
Back to the question: after sending SMS, you'll get a response from modem, smth like this: +cmgs: {sms id, 0 to 255} OK. In case, if Service Center has delivered the SMS successfully, modem will return this response: +cds: {some id which does not matter} {PDU status report}. You need just decode this PDU to obtain status report, id of original SMS and other useful data. If sent sms's ID and ID from status report are equal, you have status report exactly for your message. Note, if you remove message from modem's storage before receiving of delivery report, you'll get report which will be containing all usual information, but status of delivery will be most likely 71 instead of 0.

How Can I Use xmpp4r To Detect The Online/Offline Status Of A Given Jabber ID?

What is the proper xmpp4r way to know if a given contact is online before sending them a message?
Can you post sample xmpp4r code for doing this?
Here is my use case:
If contact online, send :normal message
Else, email contact
Here are things I have working code for:
Send messages of various types
Get a roster/contact list
Register a call back to detect changes in presence
However, I can't find a place that directly addresses a work flow like this:
Loop through each JID in your roster
If jid.is_online? == true, send IM
Else, send email
I've read that you should send a JID a message of type :headline and if that fails, you know the user is offline. In my tests, if the user is ONLINE, they'll receive a message of type headline. This is suboptimal, as users should only receive messages to read, not noise to determine online status.
I've read that on sign on, all of your contacts will bounce a presence status back at you, and that status is the sole indication that they are online - assuming that there isn't a disconnect or presence change you've yet to receive. So you should register a presence call back, record the initial users who ping you back, and then add or remove from the list based on your running roster presence callback.
If this is truly the way to do it:
Can I get some example code of how to collect all the "I'm here" presence confirmations on sign on via xmpp4r?
Why, oh why, was xmpp designed this way and why is this better than offering an "is_online_and_available" method?
So the answer here is adding a message call back and checking inside the block for the type:
m = Message.new(to, body)
cl.send(m)
cl.add_message_callback do |m|
if m.type == :error
puts "type: #{m.type}"
else
puts "not an error"
end
end
This requires threading as you have to be listening for the response.

Resources