Slack API clinet library for C#.
Currently support for only Incoming WebHooks API.
from NuGet - SlackSharp
PM > Install-Package SlackSharp
Create an instance of WebHookClient
with a serializer instance implementing IHttpContentJsonSerializer
.
Call SendAsync
method with arguments that are Incoming-WebHooks URL and a message.
using (var client = new WebHookClient(new JsonNetSerializer()))
{
// Simple message
{
var response = await client.SendAsync("[Your Incoming WebHooks URL]", "Hello Slack");
}
// Strcutured message
{
var payload = new Payload
{
Channel = "random",
Username = "an user",
Text = "Hello Slack"
};
var response = await client.SendAsync("[Your Incoming WebHooks URL]", payload);
}
}
Provides serializers implementing Json.NET(Standard JSON Library of .NET), Jil(Fastest Text-Format JSON Library) or Utf8Json(Fastest Binary-Format JSON Library).
under MIT Lisence.