2
  1. I want to send receive SMS messages using SMS gateway.

  2. When sending message I am going to ask some question and reciever sould reply.

  3. I need to add some unique id when sending the SMS, and get it back when receiving.

I know there is a way to do that, like ICQ and Google vois 2 way sms. The receiver return the message to the same number, but only the sender get it back.

Can someone help with this?

Thanks, Lior

lior haham
  • 21
  • 1
  • 3
  • I blogged about this here: https://nbevans.wordpress.com/2011/11/30/building-automated-two-way-applications-on-top-of-sms-text-messaging/ – nbevans Dec 01 '11 at 18:34

1 Answers1

4

Almost all SMS gateways allow you to send and receive messages. The most common method for sending messages is via some sort of HTTP API (SOAP, REST, RPC). For example, to send a message using Twilio (where I work) you would make a POST request to our API with three parameters: To (the recipient), From (your Twilio number), and Body (what to include in the message). Many other gateways use similar methods.

Due to limitations of the SMS system worldwide, there is no way to uniquely identify messages. This means that unless the recipient of a message manually includes an identifier there is no way to associate a reply with the original message outside of matching the sender and recipients phone numbers. This can make it tricky to handle cases where there are multiple outstanding queries to a single recipient. There are a couple strategies you can use to get around this limitation.

  1. Request unique response tokens - For each query sent to a recipient, require the response to be unique to that query. For instance, on the first message use something like, "To confirm, respond with A1" and on subsequent outstanding queries use a different unique response.

  2. Use different 'From' phone numbers - For each query sent to a recipient, send from a different number. Then you can match the response to the phone number responded to. This is not an optimal system in many cases since you need more phone numbers and users could receive messages from many different numbers resulting in confusion.

  3. Expire outstanding queries - If responses to each query aren't important, just assume they're responding to the most recent, or prompt them for clarification after a response.

In regards to receiving messages, most gateways will notify you via HTTP. As an example, when a message comes into your Twilio number, we make a POST request to a URL that you specify with the To, From and Body parameters included. You handle this like any other form submission in your application. Other gateways use similar methods, but I can't attest to the details.

John Sheehan
  • 77,456
  • 30
  • 160
  • 194