What is n8n?
n8n is an open-source workflow automation tool (like Zapier but self-hosted). It connects 400+ services and can be triggered by webhooks from your .NET app.
Sending a Webhook from .NET
public class WebhookService(HttpClient http, IConfiguration config)
{
public async Task NotifyPostPublishedAsync(BlogPost post)
{
var url = config["N8n:WebhookUrl"];
await http.PostAsJsonAsync(url, new
{
event = "post.published",
post.Title, post.Slug,
url = $"https://mysite.com/blog/{post.Slug}"
});
}
}
n8n Workflow: Auto-Tweet on Publish
- Webhook trigger — receives POST from .NET
- Twitter node — posts tweet with title + URL
- LinkedIn node — shares post on LinkedIn
- Email node — sends newsletter to subscribers
💡
Self-host n8n on a $5/month VPS or use n8n Cloud. The community edition is free and covers most automation needs.
HMAC Webhook Security
var signature = Convert.ToHexString(
HMACSHA256.HashData(Encoding.UTF8.GetBytes(secret),
Encoding.UTF8.GetBytes(body)));
if (signature != request.Headers["X-Signature"]) return Unauthorized();