1

I am trying to use Plivo's API to send and receive SMSs to mobile numbers in America. I want to receive their reply in my web application. like we receive message from mobile company and then reply their options in same thread usually.

I am using this code to receive the reply but not sure that where to deploy this code either to make class and put code in it or call it to my webservice.asmx any idea please

using System;
using System.Collections.Generic;
using System.Reflection;
using Nancy;
using RestSharp;
using Plivo.API;

namespace Receive_Sms
{
    public class Program : NancyModule
    {
        public Program()
        {
            Post["/receive_sms"] = x =>
            {
                String from_number = Request.Form["From"]; // Sender's phone number
                String to_number = Request.Form["To"]; // Receiver's phone number
                String text = Request.Form["Text"]; // The text which was received

                // Print the message
                Console.WriteLine("Message received - From: {0}, To: {1}, Text: {2}", from_number, to_number, text);

                return "Message received";
            };
        }
    }
}

I am also open to using other providers than Plivo.

Nasreddine
  • 36,610
  • 17
  • 75
  • 94
Junaid
  • 316
  • 5
  • 23
  • Use [Twilio](https://www.twilio.com/) or any other similar service. – Nasreddine May 25 '16 at 13:24
  • @Nasreddine i am using pvilo same likeTwilio, but I can't receive reply from user. Can you help me for this thing ? – Junaid May 25 '16 at 13:26
  • 1
    You should put that in your question along with your code to get proper help on how to proceed. As it is now it looks like you're just looking for recommendations. – Nasreddine May 25 '16 at 13:28

2 Answers2

1

To receive messages on your Plivo number, you will have to configure the "Message URL" of the Plivo Application attached to that number. Steps to create a Plivo application are here and steps to attach that application to your Plivo number are here.

Next, you'll have to host your code publicly so that Plivo can send requests to your .Net application. You could use platforms like Microsoft Azure or Appharbor to host your .Net code. After deployment, use your hosted application URL (like https://yourapp.appharbor.com/receive_sms) to configure the Message URL in your Plivo Application created in the previous step.

To reply to incoming messages, your Message URL should return a Message XML. You can find these instructions here. More details about Message XML here.

Ramya Raghu
  • 409
  • 3
  • 4
-1

Most US carriers have an email address you can send emails to that will then be automatically texted to the mobile phone. All you have to do is use an SMTPClient to send the email. Google "us email to text" to get the appropriate addresses for each carrier.

Lews Therin
  • 3,707
  • 2
  • 27
  • 53