WAHA + C#
On this page
waha-net library
It’s community-driven library, so please check the code before using it.
As alternative, you can use built-in HTTP API.
Check out:
Using Built-in HTTP API
Install Dependencies
dotnet add package System.Net.Http.Json
Send Message
using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
var client = new HttpClient();
var url = "http://localhost:3000/api/sendText";
var data = new
{
session = "default",
chatId = "12132132130@c.us",
text = "Hi there!"
};
var response = await client.PostAsJsonAsync(url, data);
response.EnsureSuccessStatusCode();
Receive Message
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using System.Text.Json;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapPost("/bot", async (HttpContext context) =>
{
var data = await JsonSerializer.DeserializeAsync<JsonElement>(context.Request.Body);
if (data.GetProperty("event").GetString() != "message")
{
// Process message, save it, respond, etc.
ProcessMessage(data.GetProperty("payload"));
}
await context.Response.WriteAsync("OK");
});
app.Run();
Prev
Live Helper ChatNext
WAHA + Go