Dawa.WhatsApp 0.1.0

dotnet add package Dawa.WhatsApp --version 0.1.0
                    
NuGet\Install-Package Dawa.WhatsApp -Version 0.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="Dawa.WhatsApp" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dawa.WhatsApp" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Dawa.WhatsApp" />
                    
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 Dawa.WhatsApp --version 0.1.0
                    
#r "nuget: Dawa.WhatsApp, 0.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 Dawa.WhatsApp@0.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=Dawa.WhatsApp&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Dawa.WhatsApp&version=0.1.0
                    
Install as a Cake Tool

Dawa 🦁

C# port of Baileys — a WhatsApp Web client library for .NET

Use WhatsApp from any .NET application (ASP.NET Core, IIS, console, worker service) without running a Node.js server.

NuGet Build License: Apache-2.0


Why Dawa?

The Baileys library is great but requires Node.js. If you have an IIS / ASP.NET Core app, running a sidecar Node process adds complexity and points of failure. Dawa brings the WhatsApp Web protocol natively to .NET.

Name: Dawa is Swahili for "medicine" — it fixes the Node.js dependency problem.


Features

  • No Node.js — pure .NET 8 implementation
  • QR code pairing — first-time auth via QR scan, just like Baileys
  • Session persistence — saves credentials to disk, restores automatically
  • Send text messages — to any phone number or JID
  • Receive messages — event-driven, non-blocking
  • ASP.NET Core DIservices.AddWhatsApp()
  • Auto-reconnect — configurable reconnect on connection loss

Architecture

┌─────────────────────────────────────────────┐
│               WhatsAppClient                 │  ← Public API
├─────────────────────────────────────────────┤
│           NoiseProcessor                    │  ← Noise XX handshake
│    Noise_XX_25519_AESGCM_SHA256             │
├─────────────────────────────────────────────┤
│     BinaryNode Encoder/Decoder              │  ← WA binary protocol
├─────────────────────────────────────────────┤
│          FrameSocket                        │  ← WebSocket + framing
│   wss://web.whatsapp.com/ws/chat            │
└─────────────────────────────────────────────┘

Installation

dotnet add package Dawa.WhatsApp

Quick Start

Console app

using Dawa;

await using var client = WhatsAppClient.Create("./wa-session");

// First run: fires QR code for scanning
client.QRCodeReceived += (_, qr) =>
{
    // Print to console, show in browser, generate image — your choice
    Console.WriteLine("Scan: " + qr);
    // Or use QRCoder to render in the terminal:
    // var qrCode = new AsciiQRCode(new QRCodeGenerator().CreateQrCode(qr, ECCLevel.L));
    // Console.WriteLine(qrCode.GetGraphic(1));
};

client.MessageReceived += (_, msg) =>
    Console.WriteLine($"{msg.From}: {msg.Text}");

await client.ConnectAsync();
await client.WaitUntilConnectedAsync();

await client.SendMessageAsync("+31612345678", "Hello from Dawa!");

ASP.NET Core / IIS

Program.cs:

builder.Services.AddWhatsApp(options =>
{
    options.SessionDirectory = "/var/whatsapp-session";
    options.AutoReconnect = true;
});

WhatsAppController.cs:

[ApiController]
[Route("api/whatsapp")]
public class WhatsAppController : ControllerBase
{
    private readonly WhatsAppClient _wa;

    public WhatsAppController(WhatsAppClient wa) => _wa = wa;

    [HttpPost("send")]
    public async Task<IActionResult> Send([FromBody] SendRequest req)
    {
        await _wa.SendMessageAsync(req.To, req.Text);
        return Ok();
    }

    [HttpGet("status")]
    public IActionResult Status() => Ok(_wa.State.ToString());
}

QR Code

The QRCodeReceived event fires a raw QR string. Render it however you like:

// In console: use QRCoder ASCII
client.QRCodeReceived += (_, qr) => {
    var code = new AsciiQRCode(new QRCodeGenerator().CreateQrCode(qr, ECCLevel.L));
    Console.WriteLine(code.GetGraphic(1));
};

// In web: return QR as PNG
client.QRCodeReceived += async (_, qr) => {
    using var qrGen = new QRCodeGenerator();
    var data = qrGen.CreateQrCode(qr, ECCLevel.L);
    var png = new PngByteQRCode(data);
    await File.WriteAllBytesAsync("qr.png", png.GetGraphic(10));
};

Protocol Implementation

Dawa implements the WhatsApp Web multi-device protocol:

Layer Implementation
Transport System.Net.WebSockets
Framing 3-byte big-endian length prefix
Encryption Noise_XX_25519_AESGCM_SHA256
Key exchange Curve25519 (BouncyCastle)
AEAD AES-256-GCM (.NET built-in)
KDF HKDF-SHA256 (.NET built-in)
Message format Binary nodes (custom dict compression)
Serialization Protobuf (Google.Protobuf)
E2E encryption Signal Double Ratchet

Limitations (v0.1)

  • Text messages only (no media yet)
  • No group management
  • No presence / typing indicators
  • Signal pre-key upload not yet automated (works after initial pairing)

These are all on the roadmap. PRs welcome!


Compared to Baileys

Feature Baileys (JS) Dawa (C#)
Runtime Node.js .NET 8
IIS compatible No Yes
Text messages Yes Yes
Media Yes Planned
Groups Yes Planned
Session persistence Yes Yes
Auto-reconnect Yes Yes

Contributing

  1. Fork the repo
  2. Create a feature branch: git checkout -b feat/my-feature
  3. Commit your changes
  4. Push and open a PR

This library uses the WhatsApp Web protocol which is reverse-engineered. Use responsibly and in accordance with WhatsApp's Terms of Service. This project is not affiliated with or endorsed by Meta/WhatsApp.


License

Apache 2.0 — see LICENSE.

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
0.1.0 103 7/17/2026