DeltaCore.SMSService 1.1.0

dotnet add package DeltaCore.SMSService --version 1.1.0
                    
NuGet\Install-Package DeltaCore.SMSService -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DeltaCore.SMSService" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DeltaCore.SMSService" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="DeltaCore.SMSService" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DeltaCore.SMSService --version 1.1.0
                    
#r "nuget: DeltaCore.SMSService, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DeltaCore.SMSService@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DeltaCore.SMSService&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=DeltaCore.SMSService&version=1.1.0
                    
Install as a Cake Tool

SMSService

DeltaCore.SMSService

Overview 📚

DeltaCore.SMSService is a lightweight .NET 8 library that simplifies sending and verifying OTPs via SMS or call using Twilio Verify API, and sending custom messages using Twilio Messaging API.
It also includes a simple throttling mechanism to prevent sending OTPs within 60 seconds to the same number.

✅ Send OTPs via SMS or call
✅ Verify OTPs easily
✅ Send custom text messages
✅ Prevent spamming (resending OTP within 60 seconds)
✅ Built-in error handling and logging


Install from NuGet 📦

You can install the package from NuGet:

dotnet add package DeltaCore.SMSService

or via the Package Manager Console:

Install-Package DeltaCore.SMSService

Using in Your App 🚀

  • Configure TwilioSettings In your appsettings.json, add:
{
  "TwilioSettings": {
    "AccountSID": "your_account_sid",
    "AuthToken": "your_auth_token",
    "TwilioPhoneNumber": "your_twilio_phone_number",
    "VerifyServiceSID": "your_verify_service_sid"
  }
}
  • Register the Service in Startup.cs or Program.cs
builder.Services.Configure<TwilioSettings>(builder.Configuration.GetSection("TwilioSettings"));
builder.Services.AddSingleton<ISMSService, TwilioService>();
  • Using ISMSService in Your Application Inject ISMSService where needed, for example in a controller or service:
public class AccountController : ControllerBase
{
    private readonly ISMSService _smsService;

    public AccountController(ISMSService smsService)
    {
        _smsService = smsService;
    }

    [HttpPost("send-otp")]
    public async Task<IActionResult> SendOtp(string phoneNumber)
    {
        var verificationSid = await _smsService.SendOTPAsync(phoneNumber);
        if (verificationSid == null)
            return BadRequest("OTP was sent recently. Please wait.");
        
        return Ok(new { verificationSid });
    }

    [HttpPost("verify-otp")]
    public async Task<IActionResult> VerifyOtp(string phoneNumber, string code)
    {
        var isValid = await _smsService.VerifyOTPAsync(phoneNumber, code);
        if (!isValid)
            return BadRequest("Invalid or expired OTP.");

        return Ok("OTP verified successfully.");
    }

    [HttpPost("send-message")]
    public async Task<IActionResult> SendMessage(string phoneNumber, string message)
    {
        var isSent = await _smsService.SendMessageAsync(phoneNumber, message);
        if (!isSent)
            return BadRequest("Failed to send message.");

        return Ok("Message sent successfully.");
    }
}

Important Notes 📝

  • OTP requests are rate-limited: the same number cannot request a new OTP within 60 seconds.

  • Errors during sending/verification are logged using ILogger.

  • Supports both SMS and voice calls when sending OTPs by specifying the channel parameter.


License 🛡️

This project is licensed under the MIT License.


Support

If you encounter any issues or have questions about using DeltaCore.SMSService, feel free to create an issue on GitHub or reach out to us.


Author

👤 Ahmed Nady

GitHub LinkedIn Gmail

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 274 6/15/2025
1.0.0 238 4/28/2025