You can sign up with Plivo and start with a free trial account to experiment with and learn about our services. This free trial account comes with free credits. If you wish to continue with our service, you can add more credits and buy a number by clicking here. Add a number and credits to your account to test the full range of our voice and SMS service features.
Sign up here to get your free Plivo account today.
Follow these steps to sign up for a free trial account:
If you have any issues creating a Plivo account, please reach out to our Support Team for assistance.
You must set up and install Dotnet Core(.NET Core 1.0 or higher) and Plivo’s Dotnet SDK to make send first SMS. Here’s how.
Operating System | Instructions |
---|---|
OS X & Linux | You would already have Dotnet Core installed, you can check this by running the command dotnet --version in the terminal. If you do not have it installed, you can install it from here. |
Windows | To install Dotnet Core on Windows you can follow the instructions from here. |
Create a project directory, run the following command:
$ mkdir mydotnetcoreapp
Change the directory to our project directory in the command line:
$ cd mydotnetcoreapp
Install the SDK using Dotnet CLI. You can follow the below commands to install Plivo SDK using Dotnet CLI
$ dotnet new console
$ dotnet add package Plivo --version 4.9.0
This section will guide you through how to use Plivo APIs to Send SMS from your application. First, let’s make sure you meet these prerequisites before we dive into the code.
Now, open the file in the CS project called Program.cs
and paste the below code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using System;
using System.Collections.Generic;
using Plivo;
namespace testplivo
{
internal class Program
{
public static void Main(string[] args)
{
var api = new PlivoApi("auth_id", "auth_token");
var response = api.Message.Create(
src: "plivo_src_number",
dst: new List<String> { "the_destination_number" },
text: "Hello, this is test message"
);
Console.WriteLine(response);
}
}
}
Save the file and use the below command to run it.
dotnet run
In this section, we’ll walk you through how to set up a .Net Framework app in under five minutes and start handling incoming messages & callbacks.
Plivo supports receiving SMS text messages in 9 countries (see complete SMS API coverage). When an SMS is sent to a Plivo phone number, you can receive the text on your server by setting a Message URL in your Plivo app. Plivo will send the message along with other parameters to your Message URL.
Create a project directory, run the following command:
$ mkdir receivesmsapp
Change the directory to our project directory in the command line:
$ cd receivesmsapp
Initialize MVC architecture using the below command:
$ dotnet new mvc --no-https
Install the Plivo .Net package
$ dotnet add package Plivo --version 4.9.0
Navigate to Controllers directory in “receivesmsapp” directory and create a Controller called ReceiveSmsController.cs paste the following code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using Microsoft.AspNetCore.Mvc;
namespace ReceiceSms.Controllers
{
public class ReceiveSmsController : Controller
{
// GET: /<controller>/
public String Index()
{
// Sender's phone number
String from_number = Request.Form["From"];
// Receiver's phone number
String to_number = Request.Form["To"];
// The text which was received
String text = Request.Form["Text"];
// Print the message
Console.WriteLine("Message received - From: {0}, To: {1}, Text: {2}", from_number, to_number, text);
return "Message received";
}
}
}
Before starting the app, you have to update Properties/launchSettings.json by setting the applicationUrl as
"applicationUrl": "http://localhost:5000/"
Use the below command to start the local server:
dotnet run
And you should see your basic server app in action on http://localhost:5000/receivesms/
To receive Incoming Calls and to handle callbacks, your local server should be able to connect with Plivo API service, Ngrok is a tunneling software used to expose a web server running on your local machine to the internet. Using Ngrok you can set webhooks which can talk to Plivo server.
You can download and install ngrok from here. Follow the detailed configuration instructions to get started.
Run ngrok on the port which currently hosts your application. For example, if your port number is 80, run the following command:
./ngrok http <port_on_which_your_local_server_is_running>
This will give you a UI with links that look like ngrok.io/*
which you can use to access your local server using the public network.
New Application
. You can also use Plivo’s Application API.Receive SMS
. Enter your server URL (e.g. http://example.com/receive_sms/
) in the Message URL
field and set the method as POST
. See our Application API docs to learn how to modify your application through our APIs.Create
to save your application.Receive SMS
(name of the app) from the Plivo App dropdown list.Update
to save.Send an SMS to your Plivo number using a regular mobile phone. Plivo will send a request to your Message URL
with the parameters listed in the XML Request - Messages Documentation.
When an SMS is sent to an Plivo phone number, you can receive the text on your server by setting a Message URL in your Plivo app. Plivo will send the message along with other parameters to your Message URL. You can reply back using the Plivo Message XML.
Create a Controller called ReplytoInboundController.cs in “Controllers Directory” and paste the below code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
namespace ReceiceSms.Controllers
{
public class ReplytoInboundController : Controller
{
// GET: /<controller>/
public IActionResult Index()
{
Plivo.XML.Response resp = new Plivo.XML.Response();
resp.AddMessage("Hi, message from Plivo.",
new Dictionary<string, string>()
{
{"src", "+12023222222"},
{"dst", "+15671234567" } ,
{"type", "sms"},
{"callbackUrl", "http://foo.com/sms_status/"},
{"callbackMethod", "POST"}
});
var output = resp.ToString();
Console.WriteLine(output);
return this.Content(output, "text/xml");
}
}
}
Send an SMS to your Plivo number using a regular mobile phone and an automatic response will be sent from your Plivo number to your mobile phone. Also, Plivo will send a request to your Message URL
with the parameters listed in the XML Request - Messages Documentation.