SlackWebhook
SlackWebhook
Contents
ActionStyle type
typeNamespace
SlackWebhook.Enums
Summary
Action type
Danger constants
constantsSummary
Turns the button red and indicates it some kind of destructive action
Primary constants
constantsSummary
Turns the button green and indicates the best forward action to take
ActionStyleJsonConverter type
typeNamespace
SlackWebhook.Core
Summary
ActionStylejson converter
ReadJson() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
WriteJson() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
FormattedTextEncoder type
typeNamespace
SlackWebhook.Core
Summary
Handles escaping characters which the Slack webhook expects to be HTML encoded.
See https://api.slack.com/docs/message-formatting#how_to_escape_characters for more.
ICloneable`1 type
typeNamespace
SlackWebhook.Core
Summary
Cloneable type
Generic Types
Name
Description
T
Type of clone
Clone() method
methodSummary
Creates new clone of this instance
Returns
Cloned instance
Parameters
This method has no parameters.
IconType type
typeNamespace
SlackWebhook.Enums
Summary
Icon type
Emoji constants
constantsSummary
Icon is a slack emoji name, e.g.
smileUrl constants
constantsSummary
Icon is a image URL
ISlackAttachmentBuilder type
typeNamespace
SlackWebhook
Summary
Slack attachment builder used to configure an attachment to be added to a SlackMessage
WithAuthor(name,linkUrl,iconUrl) method
methodSummary
With author name, and optional link url and icon url
Parameters
Name
Type
Description
Remarks
The author parameters will display a small section at the top of a message attachment.
A valid URL that will hyperlink the AuthorNametext mentioned above. Will only work if AuthorNameis present.
A valid URL that displays a small 16x16px image to the left of the AuthorNametext. Will only work if AuthorNameis present.
WithColor(hexColor) method
methodSummary
With hex-based color
Parameters
Name
Type
Description
Remarks
Like traffic signals, color-coding messages can quickly communicate intent and help separate them from the flow of other messages in the timeline.
An optional value that can either be one of good, warning, danger, or any hex color code(eg. #439FE0). This value is used to color the border along the left side of the message attachment.
WithColor(color) method
methodSummary
With color from Colorinstance
Parameters
Name
Type
Description
WithFallback(fallback) method
methodSummary
With required plain-text summary of the attachment
Returns
Parameters
Name
Type
Description
Remarks
A plain-text summary of the attachment. This text will be used in clients that don't show formatted text (eg. IRC, mobile notifications) and should not contain any markup.
WithField(title,value,isShort,enableFormatting) method
methodSummary
With attachment field shown as a table inside the message attachment
Parameters
Name
Type
Description
Shown as a bold heading above the value text. It cannot contain markup and will be escaped for you. | | value | System.String | Value of field (may contain formatting if enabled)
The text value of the field. It may contain standard message markup and must be escaped as normal. May be multi-line. | | isShort | System.Boolean | Whether field can be shown side-by-side with other fields (optional) | | enableFormatting | System.Boolean | Whether or not to enable formatting for value |
Remarks
If enableFormattingis enabled, you can use Slack message formatting in valueand it will automatically be encoded according to slack encoding rules.
WithFooter(text,iconUrl) method
methodSummary
With footer text and optional footer icon
Returns
Parameters
Remarks
Add some brief text to help contextualize and identify an attachment. Limited to 300 characters, and may be truncated further when displayed to users in environments with limited screen real estate.
To render a small icon beside your footer text, provide a publicly accessible URL string in the footer_icon field. You must also provide a footer for the field to be recognized.
We'll render what you provide at 16px by 16px. It's best to use an image that is similarly sized.
WithImage(url) method
methodSummary
With image url
Parameters
Name
Type
Description
Remarks
A valid URL to an image file that will be displayed inside a message attachment. We currently support the following formats: GIF, JPEG, PNG, and BMP.
Large images will be resized to a maximum width of 400px or a maximum height of 500px, while still maintaining the original aspect ratio.
WithLink(url) method
methodSummary
With link on attachment title
Parameters
Name
Type
Description
Remarks
Link of title (optional)
WithLinkButtonAction(text,url,style) method
methodSummary
With link button action, shown at the bottom of the attachment
Parameters
Name
Type
Description
Remarks
An attachment may contain multiple actions
WithPreText(text,enableFormatting) method
methodSummary
With optional pre-text
Parameters
Name
Type
Description
Remarks
This is optional text that appears above the message attachment block.
WithText(text,enableFormatting) method
methodSummary
With optional text
Parameters
Name
Type
Description
Remarks
This is the main text in a message attachment, and can contain standard message markup. The content will automatically collapse if it contains 700+ characters or 5+ linebreaks, and will display a "Show more..." link to expand the content. Links posted in the text field will not unfurl.
If enableFormattingis enabled, you can use Slack message formatting in textand it will automatically be encoded according to slack encoding rules.
WithThumbnail(url) method
methodSummary
With thumbnail url
Parameters
Name
Type
Description
Remarks
A valid URL to an image file that will be displayed as a thumbnail on the right side of a message attachment. We currently support the following formats: GIF, JPEG, PNG, and BMP.
The thumbnail's longest dimension will be scaled down to 75px while maintaining the aspect ratio of the image. The filesize of the image must also be less than 500 KB.
For best results, please use images that are already 75px by 75px.
WithTimestamp(timestamp) method
methodSummary
With timestamp based on timestamp
Parameters
Name
Type
Description
Remarks
Does your attachment relate to something happening at a specific time?
By providing the ts field with an integer value in "epoch time", the attachment will display an additional timestamp value as part of the attachment's footer.
Use ts when referencing articles or happenings.Your message will have its own timestamp when published.
Example: Providing 123456789 would result in a rendered timestamp of Nov 29th, 1973.
WithTimestamp(epochTime) method
methodSummary
With epoc timestamp
Parameters
Name
Type
Description
Remarks
Does your attachment relate to something happening at a specific time?
By providing the ts field with an integer value in "epoch time", the attachment will display an additional timestamp value as part of the attachment's footer.
Use ts when referencing articles or happenings.Your message will have its own timestamp when published.
Example: Providing 123456789 would result in a rendered timestamp of Nov 29th, 1973.
WithTitle(title) method
methodSummary
With required title
Parameters
Name
Type
Description
Remarks
The title is displayed as larger, bold text near the top of a message attachment. By passing a valid URL in the TitleLinkparameter (optional), the title text will be
ISlackClient type
typeNamespace
SlackWebhook
Summary
Slack client
SendAsync(configureBuilder) method
methodSummary
Send new SlackMessageby configuring the provided ISlackMessageBuilder
Parameters
Name
Type
Description
configureBuilder
Configure message to send using this builder
Exceptions
Name
Description
Thrown if validation of the message fails, such as if a required field is missing.
Uses Validateto perform validation. |
SendAsync(message) method
methodSummary
Send the provided SlackMessage
Parameters
Name
Type
Description
Exceptions
Name
Description
Thrown if validation of the message fails, such as if a required field is missing.
Uses Validateto perform validation. |
ISlackMessageBuilder type
typeNamespace
SlackWebhook
Summary
Slack message builder that produces SlackMessageinstances based on the builder's current configuration.
Build() method
methodSummary
Build SlackMessagebased on current state of the builder
Returns
New message
Parameters
This method has no parameters.
Exceptions
Name
Description
Thrown if validation of the message fails, such as if a required field is missing.
Uses Validateto perform validation. |
WithAttachment(configureAttachment) method
methodSummary
With attachment build with provided attachment builder
Parameters
Name
Type
Description
Remarks
Adds a new SlackAttachmentto Attachmentsbuilt using provided ISlackAttachmentBuilder
WithChannel(channel) method
methodSummary
With channel
Parameters
Name
Type
Description
Remarks
Sets the Channelproperty
WithIcon(iconType,urlOrEmoji) method
methodSummary
With icon (url or emoji)
Parameters
Name
Type
Description
Remarks
Sets the IconUrlor IconEmojibased on iconTypewith the provided value urlOrEmoji
WithText(text,enableFormatting) method
methodSummary
With required message text
Parameters
Name
Type
Description
Remarks
Sets the Textand EnableFormattingproperties.
If enableFormattingis enabled, you can use Slack message formatting in textand it will automatically be encoded according to slack encoding rules.
WithUsername(username) method
methodSummary
With username
Parameters
Name
Type
Description
Remarks
Sets the Usernameproperty
IValidateable type
typeNamespace
SlackWebhook.Core
Summary
Object can be validated
Validate(validationErrors) method
methodSummary
Validates the current state of the object (including any nested validateable members)
Returns
True if the object is valid, false otherwise
Parameters
Name
Type
Description
validationErrors
Validation errors (if any found)
Remarks
Will find all (if any) validation errors and populate validationErrorswith each
SlackAttachment type
typeNamespace
SlackWebhook.Messages
Summary
Optional attachment to a SlackMessage.
See https://api.slack.com/docs/message-attachments for more details
FormattingFields constants
constantsSummary
Used to enable formatting of the Fieldsvalue fields
FormattingPretext constants
constantsSummary
Used to enable formatting of the PreTextfield
FormattingText constants
constantsSummary
Used to enable formatting of the Textfield
Actions property
propertySummary
Actions shown at the bottom of the message (optional)
AuthorIcon property
propertySummary
Author icon URL (optional)
Remarks
A valid URL that displays a small 16x16px image to the left of the AuthorNametext. Will only work if AuthorNameis present.
AuthorLink property
propertySummary
Author link (optional)
Remarks
A valid URL that will hyperlink the AuthorNametext mentioned above. Will only work if AuthorNameis present.
AuthorName property
propertySummary
Author name (optional)
Remarks
The author parameters will display a small section at the top of a message attachment
Color property
propertySummary
Gets or sets the color.
Remarks
Like traffic signals, color-coding messages can quickly communicate intent and help separate them from the flow of other messages in the timeline.
An optional value that can either be one of good, warning, danger, or any hex color code(eg. #439FE0). This value is used to color the border along the left side of the message attachment.
EnableFormatting property
propertySummary
Enable formatting for various fields of the attachment, use FormattingText, FormattingPretextand FormattingFieldsto contorl which fields have formatting enabled.
Fallback property
propertySummary
Required plain-text summary of the attachment
Remarks
A plain-text summary of the attachment. This text will be used in clients that don't show formatted text (eg. IRC, mobile notifications) and should not contain any markup.
Fields property
propertySummary
Fields shown as a table inside the message attachment (optional)
Footer property
propertySummary
Footer text shown at the bottom of attachment (optional)
Remarks
Add some brief text to help contextualize and identify an attachment. Limited to 300 characters, and may be truncated further when displayed to users in environments with limited screen real estate.
FooterIcon property
propertySummary
Icon shown left of footer text (optional)
Remarks
To render a small icon beside your footer text, provide a publicly accessible URL string in the footer_icon field. You must also provide a footer for the field to be recognized.
We'll render what you provide at 16px by 16px. It's best to use an image that is similarly sized.
ImageUrl property
propertySummary
Image url (optional)
Remarks
A valid URL to an image file that will be displayed inside a message attachment. We currently support the following formats: GIF, JPEG, PNG, and BMP.
Large images will be resized to a maximum width of 400px or a maximum height of 500px, while still maintaining the original aspect ratio.
PreText property
propertySummary
Optional text that appears above the attachment block
Remarks
This is optional text that appears above the message attachment block.
Text property
propertySummary
Optional text that appears within the attachment
Remarks
This is the main text in a message attachment, and can contain standard message markup. The content will automatically collapse if it contains 700+ characters or 5+ linebreaks, and will display a "Show more..." link to expand the content. Links posted in the text field will not unfurl.
ThumbnailUrl property
propertySummary
Thumbnail url (optional)
Remarks
A valid URL to an image file that will be displayed as a thumbnail on the right side of a message attachment. We currently support the following formats: GIF, JPEG, PNG, and BMP.
The thumbnail's longest dimension will be scaled down to 75px while maintaining the aspect ratio of the image. The filesize of the image must also be less than 500 KB.
For best results, please use images that are already 75px by 75px.
Timestamp property
propertySummary
Timestamp (epoch time) shown below attachment (optional)
Remarks
Does your attachment relate to something happening at a specific time?
By providing the ts field with an integer value in "epoch time", the attachment will display an additional timestamp value as part of the attachment's footer.
Use ts when referencing articles or happenings.Your message will have its own timestamp when published.
Example: Providing 123456789 would result in a rendered timestamp of Nov 29th, 1973.
Title property
propertySummary
Title of attachment (required)
Remarks
The title is displayed as larger, bold text near the top of a message attachment. By passing a valid URL in the TitleLinkparameter (optional), the title text will be hyperlinked.
TitleLink property
propertySummary
Link of title (optional)
Clone() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
SetColor(color) method
methodSummary
Set color hex code from Color
Parameters
Name
Type
Description
SetTimestamp(timestamp) method
methodSummary
Set Timestampepoch value based on provided date time
Parameters
Name
Type
Description
Validate() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
SlackAttachmentAction type
typeNamespace
SlackWebhook.Messages
Summary
Optional action to se SlackAttachment.
#ctor(type) constructor
constructorSummary
Initialize attachment action
Parameters
Name
Type
Description
Text property
propertySummary
Text displayed for the action
Remarks
How this is presented depends on the type of action
Type property
propertySummary
Type of action
Clone() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
Validate() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
SlackAttachmentBuilder type
typeNamespace
SlackWebhook
SetEnableFormatting(formattingType,enable) method
methodSummary
Enables or disables formatting by adding/removing formattingTypefrom EnableFormatting
Parameters
Name
Type
Description
SlackAttachmentField type
typeNamespace
SlackWebhook.Messages
Summary
Optional attachment field added to Fields
Short property
propertySummary
Whether field can be shown side-by-side with other fields (optional)
Title property
propertySummary
Title of field
Remarks
Shown as a bold heading above the value text. It cannot contain markup and will be escaped for you.
Value property
propertySummary
Value of field (may contain formatting if enabled)
Remarks
The text value of the field. It may contain standard message markup and must be escaped as normal. May be multi-line.
Clone() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
Validate() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
SlackAttachmentLinkButtonAction type
typeNamespace
SlackWebhook.Messages
Summary
Button action which will open a Url, if clicked
#ctor() constructor
constructorSummary
Create new empty link button action
Parameters
This constructor has no parameters.
Style property
propertySummary
Optional style
Url property
propertySummary
URL to open if link button is clicked
Clone() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
Validate() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
SlackClient type
typeNamespace
SlackWebhook
Summary
Inherit from parent.
#ctor() constructor
constructorSummary
Inherit from parent.
Parameters
This constructor has no parameters.
SendAsync() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
SendAsync() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
SlackMessage type
typeNamespace
SlackWebhook.Messages
Summary
Basis for a Slack message which can be sent to the webhook URL
Attachments property
propertySummary
Attachments to show below message (optional)
Channel property
propertySummary
Channel the message is posted into (optional)
EnableFormatting property
propertySummary
Whether or not to enable formatting for this message
Remarks
Default true
IconEmoji property
propertySummary
Icon emoji name () (optional)
Remarks
Either provide this OR IconUrl, but not both
IconUrl property
propertySummary
Icon URL to show before username (optional)
Remarks
Either provide this OR IconEmoji, but not both
Text property
propertySummary
Message text which may contain formatting (unless EnableFormattingis deactivated) and can span multiple lines.
Remarks
You can use the regular Slack formatting
*bold* `code` _italic_ ~strike~and also include links
<URL|title>Username property
propertySummary
Username shown (optional)
Clone() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
ThrowIfInvalid() method
methodSummary
Checks the current state using Validateand throws a SlackMessageValidationExceptionwith all validations errors, if any are found.
Parameters
This method has no parameters.
Validate() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
SlackMessageBuilder type
typeNamespace
SlackWebhook
Summary
Inherit from parent.
#ctor() constructor
constructorSummary
Create new slack message builder
Parameters
This constructor has no parameters.
Build() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
WithAttachment() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
WithChannel() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
WithIcon() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
WithText() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
WithUsername() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
SlackMessageValidationException type
typeNamespace
SlackWebhook.Exceptions
Summary
Slack message validation exception
#ctor(message,validationErrors) constructor
constructorSummary
Create new validation exception
Parameters
Name
Type
Description
validationErrors
Validation errors
ValidationErrors property
propertySummary
Validations errors
ValidationError type
typeNamespace
SlackWebhook.Exceptions
Summary
Validation error details
#ctor(typeName,propertyName,error) constructor
constructorSummary
Create new validation error
Parameters
Name
Type
Description
Error property
propertySummary
Validation error
PropertyName property
propertySummary
Property which failed validation
TypeName property
propertySummary
Type where validation error occurred
ToString() method
methodSummary
Inherit from parent.
Parameters
This method has no parameters.
Last updated