How to Migrate Your .NET SMS Application from Twilio to Plivo

How to Migrate Your .NET SMS Application from Twilio to Plivo

Migrating your .NET SMS app from Twilio to Plivo is a seamless and painless process. The two companies’ API structures, implementation mechanisms, XML structure, SMS message processing, and voice call processing are similar. We wrote this technical comparison so that you can scope between Twilio and Plivo APIs for a seamless migration.

Understanding the differences between Twilio and Plivo development

Most of the APIs and features that are available on Twilio are also available on Plivo and the implementation mechanism is easier as the steps involved are almost identical. This table gives a side-side comparison of the two companies’ features and APIs. An added advantage with Plivo is that not only can you code using the old familiar API/XML method, you can also implement your use cases using PHLO (Plivo High Level Objects), a visual workflow builder that lets you create workflows by dragging and dropping components onto a canvas — no coding required.

Features and APIs Twilio Plivo Similarities Implementation Interface
SMS API: Send SMS/MMS messages Request and response variables’ structure API
PHLO
Managed number pool for US/CA Messaging Copilot Powerpack Feature parity API
Console
Geo Permissions Feature parity Console
SMS Sender ID registration Feature parity Console
Number Lookup API API Parity API
Phone number management Feature parity API
Console
Validating Requests Feature parity API
XML
Subaccounts Feature parity API
HTTP callbacks Feature parity API
XML
PHLO

Plivo offers one unique advantage: Not only can you code using APIs and XML, you can also implement your use cases using PHLO (Plivo High Level Objects), a visual workflow builder that lets you create workflows by dragging and dropping components onto a canvas — no coding required.

Plivo account creation

Start by signing up for a free trial account that you can use to experiment with and learn about our services. The free trial account comes with free credits, and you can add more as you go along. You can also add a phone number to your account to start testing the full range of our voice and SMS features. A page in our support portal walks you through the signup process.

You can also port your numbers from Twilio to Plivo, as we explain in this guide.

Migrating your .NET SMS application

You can migrate your existing application from Twilio to Plivo by refactoring the code, or you can try our intuitive visual workflow builder PHLO. To continue working with the APIs, use one of the quickstart guides to set up a development environment for your preferred language. Plivo offers server SDKs in seven languages: Python, Node.js, .NET, Java, Python, Ruby, and Go. For another alternative that lets you evaluate Plivo’s SMS APIs and their request and response structure, use our Postman collections.

How to send an SMS message

Let’s take a look at the process of refactoring the code to migrate your app from Twilio to Plivo to set up a simple Java application to send an SMS message by changing just a few lines of code.

Twilio Plivo
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;


class Program
{
    static void Main(string[] args)
    {
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);
    
        var message = MessageResource.Create(
            body: "Join Earth's mightiest heroes. Like Kevin Bacon.",
            from: new Twilio.Types.PhoneNumber("+15017122661"),
            to: new Twilio.Types.PhoneNumber("+15558675310")
        );
    
        Console.WriteLine(message.Sid);
    }
}
   
using System;
using System.Collections.Generic;
using Plivo;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
        string authId = Environment.GetEnvironmentVariable("PLIVO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("PLIVO_AUTH_TOKEN");
            var api = new PlivoApi(authId,authToken);
            var response = api.Message.Create(
                src: "+14151113333",
                dst: "+14151112222",
                text: "Hello, this is sample text",
                );
            Console.WriteLine(response);
        }
    }
}
    

Alternatively, you can implement the same functionality using one of our PHLO templates. For example, if you want to send an SMS message, your PHLO would be this:

Create PHLO for outbound SMS

How to receive and reply to SMS

You can migrate an application for receiving and replying to an incoming SMS from Twilio to Plivo just as seamlessly, as in this example:

Twilio Plivo
using System.Web.Mvc;
using Twilio.AspNet.Mvc;
using Twilio.TwiML;

namespace YourNewWebProject.Controllers
{
    public class SmsController : 
TwilioController
    {
        [HttpPost]
        public TwiMLResult Index()
        {
            var messagingResponse = new
MessagingResponse();
            messagingResponse.Message("The
Robots are coming! Head for the hills!");

            return TwiML(messagingResponse);
        }
    }
}
   
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;

namespace Replysms.Controllers
{
   public class ReplysmsController : Controller
    {
        // GET: /<controller>/
        public IActionResult Index()
        {
            String from_number
            = Request.Form["From"];
            String to_number =
            Request.Form["To"];
            String text = Request.Form["Text"];
			Plivo.XML.Response 
      resp = new Plivo.XML.Response();
resp.AddMessage(
    "Thank you, we have received your
    request.",new Dictionary<string, string>()
			{
				{"src", to_number},
				{"dst", from_number},
				{"type", "sms"},
				{"callbackUrl",
"http://foo.com/sms_status/"},
				{"callbackMethod", "POST"}
			});
			var output = resp.ToString();
			Console.WriteLine(output);
			return this.Content(output, 
      "text/xml");
		}
    }
}
    

Here again, you can implement the same functionality using one of our PHLO templates. Your PHLO would look like:

With Dynamic Payload

For more information about migrating your SMS applications to Plivo, check out our detailed use case guides, available for all seven programming languages and PHLO.

How to send an MMS message

Let’s take a look at the process of refactoring the code to migrate your app from Twilio to Plivo to set up a simple Java application to send an MMS message by changing just a few lines of code.

Twilio Plivo
using System;
using System.Linq;
using Twilio;
using Twilio.Rest.Api.V2010.Account;


class Program
{
    static void Main(string[] args)
    {
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);
    
        var mediaUrl = new [] {
            new Uri("https://c1.staticflickr.com/3/2899/14341091933_1e92e62d12_b.jpg")
        }.ToList();
    
        var message = MessageResource.Create(
            body: "This is the ship that made the Kessel Run in fourteen parsecs?",
            from: new Twilio.Types.PhoneNumber("+15017122661"),
            mediaUrl: mediaUrl,
            to: new Twilio.Types.PhoneNumber("+15558675310")
        );
    
        Console.WriteLine(message.Sid);
    }
}
   
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;

namespace SdkTestDotnet
{
    class Program
    {
        static void Main(string[] args)
        {
        string authId = Environment.GetEnvironmentVariable("PLIVO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("PLIVO_AUTH_TOKEN");
            var api = new PlivoApi(authId,authToken);
            try
            {
            var response = api.Message.Create(
                src:"+14151234567",
                dst:"+14157654321",
                text:"Hello, from Dotnet!",
                type:"mms",
                media_urls: 
                new string[]{"https://media.giphy.com/media/26gscSULUcfKU7dHq/source.gif"},
                media_ids: new String[]{"801c2056-33ab-499c-80ef-58b574a462a2"}
                );
                Console.WriteLine(response);
            }
            catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    }
}

Alternatively, you can implement the same functionality using one of our PHLO templates. For example, if you want to send an MMS message, your PHLO would look like this:

Create PHLO for outbound MMS

More use cases

You can migrate your applications serving other use cases too.

Simple and reliable

And that’s all there is to migrate your .NET SMS application from Twilio to Plivo. Our simple APIs work in tandem with our Premium Communications Network to guarantee the highest possible delivery rates and the shortest possible delivery times for your SMS messages. See for yourself — sign up for a free trial account.

Get Volume Pricing

Thousands of businesses in more than 220 countries trust Plivo’s cloud communications platform

The best communications platform forthe world’s leading entertainment service

Frequently asked questions

No items found.
footer bg

Subscribe to Our Newsletter

Get monthly product and feature updates, the latest industry news, and more!

Thank you icon
Thank you!
Thank you for subscribing
Oops! Something went wrong while submitting the form.

POSTS YOU MIGHT LIKE