Adding outgoing caller id mvc asp net


ASP.NET is a popular programming language used for building web applications. In this article, we will explore how to add outgoing caller ID functionality in an MVC ASP.NET application.

Step 1: Set up Twilio Account

In order to add outgoing caller ID functionality, we need to use the Twilio API. First, sign up for a Twilio account and obtain your Account SID and Auth Token. credentials will be used to authenticate your requests to the Twilio API.

Step 2: Install Twilio NuGet Package

Next, we need to install the Twilio NuGet package in our ASP.NET MVC project. Open the Package Manager Console and run the following :

Install-Package Twilio

Step 3: Create a TwilioService Class

Now, let's create a TwilioService class that will the logic for outgoing with caller ID. Here's an example implementation:

public class TwilioService
    private readonly  accountSid;
    private readonly string authToken;

    public TwilioService(string accountSid, string authToken)
        this.accountSid = accountSid;
        this.authToken = authToken;

    public void MakeOutgoingCall(string fromNumber, string toNumber, string callerId)
        TwilioClient.Init(accountSid, authToken);

        var callOptions = new CallOptions
            From = new PhoneNumber(fromNumber),
            To = new PhoneNumber(toNumber),
            CallerId = new PhoneNumber(callerId)

        var call = CallResource.Create(callOptions);

In the above code, we create a TwilioService class that takes the Account SID and Auth Token as parameters. The MakeOutgoingCall is responsible for making the outgoing call with the specified caller ID.

Step 4: Use TwilioService in Controller

Now, let's use the TwilioService in our ASP.NET MVC controller to make an outgoing call. Here's an example:

public class HomeController : Controller
    private readonly TwilioService twilioService;

    public HomeController()
        string accountSid = "YOUR_ACCOUNT_SID";
        string authToken = "YOUR_AUTH_TOKEN";
        twilioService = new TwilioService(accountSid, authToken);

    public ActionResult MakeCall()
        string fromNumber = "YOUR_TWILIO_PHONE_NUMBER";
        string toNumber = "RECIPIENT_PHONE_NUMBER";
        string callerId = "YOUR_CALLER_ID";

        twilioService.MakeOutgoingCall(fromNumber, toNumber, callerId);

        return View();

In the above code, we create a HomeController class that uses the TwilioService to make an outgoing call. Replace “YOUR_ACCOUNT_SID”, “YOUR_AUTH_TOKEN”, “YOUR_TWILIO_PHONE_NUMBER”, “RECIPIENT_PHONE_NUMBER”, and “YOUR_CALLER_ID” with your actual Twilio account details and phone numbers.

Step 5: Create a View

Finally, let's create a view to trigger the MakeCall action in our HomeController. Here's an example:

In the above code, we create a simple view with a button that the MakeCall action in the HomeController when clicked.


In this article, we have learned how to add outgoing caller ID functionality in an MVC ASP.NET application the Twilio API. By following the steps outlined above, you can easily integrate this feature into your own web application.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents