Skip to content

Lightweight .Net Standard library for posting Slack messages or attachments via webhook integration.

License

Notifications You must be signed in to change notification settings

manxjason/SlackHelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SlackHelper

Lightweight async .Net Standard library for posting Slack messages or attachments via webhook integration.

Install

Install-Package ManxJason.SlackHelper

Usage

Send a plain text message

ISlackHelper helper = new SlackHelper(
        new Uri("your slack webhook uri"));

HttpResponseMessage result = await helper.SendAsync("your message");

Send attachment(s)

Supports single Attachment or Attachment[]

ISlackHelper helper = new SlackHelper(
        new Uri("your slack webhook uri"));

Attachment attachment = new Attachment
    {
        Fallback = "Fallback message",
        PreText = "Pre-text at the start of message",
        Text = "Enter text here",
        Color = "warning or #####",
        Fields = new Field[]
            {
                new Field("title", "value", true), 
                new Field("title", "value")
            },
        AuthorName = "manxjason"
        //additional properties..
            };

 HttpResponseMessage result = await helper.SendAsync(attachment);

Send your own slack compliant message (see Slack documentation)

ISlackHelper helper = new SlackHelper(
        new Uri("your slack webhook uri"));

var myMessage = new {text = "your message"};

 HttpResponseMessage result = await helper.SendAsync(attachment);

About

Lightweight .Net Standard library for posting Slack messages or attachments via webhook integration.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages