A free and open source .NET NuGet package to facilitate sending OTP messages through WhatsApp Business APIs. This package provides a simple and efficient way to deliver OTP messages, ensuring they reach your users swiftly and securely.
Contact Email - contact@evotechcraft.com
Support mail: support@evotechcraft.com
- Easy integration with WhatsApp Business APIs.
- Send OTP messages with minimal setup.
- Secure and reliable delivery.
- Lightweight and efficient.
WhatsApp Api Otp Demo Git Repository - https://github.com/evotechcraft/WhatsApp.Api.Demo
To install the package, use the NuGet Package Manager Console: Install-Package WhatsApp.Api.Otp
Or use the .NET CLI: dotnet add package WhatsApp.Api.Otp
Here's a basic example of how to use the WhatsApp.Api.Otp in your project:
using Microsoft.AspNetCore.Mvc;
using WhatsApp.Api.Otp.Common.Request;
using WhatsApp.Api.Otp.Contracts;
namespace whatsapp_otp_api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class WhatsappMessageController : ControllerBase
{
private IWAOtpService _wAOtp;
public WhatsappMessageController(IWAOtpService wAOtp)
{
_wAOtp = wAOtp;
}
[HttpPost("SendOtpMessage")]
public async Task<IActionResult> SendOtpMessage(OtpMessageModel message)
{
var response = await _wAOtp.SendOtpMessageAsync(message);
if (!response.IsSuccess)
{
return BadRequest(response);
}
return Ok(response);
}
}
}
"WhatsAppConfigurations": {
"ApiUrl": "https://graph.facebook.com",
"PhoneNumberId": "{{PhoneNumberId}}",
"AccessToken": "{{AccessToken}}",
"Version": "v20.0"
}
Replace placeholders like "{{PhoneNumberId}}"
and "{{AccessToken}}"
with the appropriate details as necessary.
/// <summary>
/// Adds WhatsApp.Api.Otp dependencies to the service collection.
/// </summary>
/// <param name="service">The service collection.</param>
/// <param name="configuration">The configuration.</param>
/// <param name="configSectionName">The name of the configuration section (optional).</param>
builder.Services.AddWAApiDependency(builder.Configuration, "WhatsAppConfigurations");
public class OtpMessageModel
{
public string TemplateName { get; set; }
public string RecipientNumber { get; set; }
public string Otp { get; set; }
public ETemplateLanguage Language { get; set; }
}
This project is licensed under the MIT License. See the LICENSE file for more details.
If you will face any issues with the usage of this package please raise one so that we can quickly fix it as soon as possible.
This is an open-source project under MIT License
so anyone is welcome to contribute from typos, to source code to documentation.