SlackWebHooks.Net is a fast, simple and lightweight (no dependencies) library to push rich messages and attachments to Slack's Incoming webhook API from .Net and .Net Core
Sending a simple text message to a slack channel :
// Replace the url with your own Slack Webhook URL
var client = new SlackClient("https://hooks.slack.com/services/D5D0SJ...");
// Sending to a slack channel(s) Synchronously
bool result = client.SendMessage("Hello world " + Emoji.People.smile);
// Sending to a slack channel(s) Asynchronously
var result2 = client.SendMessageAsync("Hello world Async " + Emoji.Places.airplane);
Sending a Message wirh attachments :
var client = new SlackClient("https://hooks.slack.com/services/BEGA0S...");
var msg = new Message {
text = "Invoices recorded *today*",
mrkdwn = true,
username = "MyShop"
};
msg.attachments.Add(new MessageAttachment {
pretext = "N° *B2018-3212*",
pretext_mrkdwn = true,
title = "Recorded at 14:11:02",
text = "more details here ...",
text_mrkdwn = false,
color = "#11aa11"
});
// Eventually adding other MessageAttachments ...
client.SendMessage(msg);
- Install this package from NuGet SlackWebHooks.Net
- More informations on how to generate your Slack Webhook URL here
Chtiwi Malek on Google+About the author :
Malek Chtiwi is the man behind Codicode.com
34 years old full stack developer.
Loves technology; but also likes design, photography and composing music.