A comprehensive Slack API client for .NET
RichTextList.Offset
property.RichTextQuote.Border
property.RichTextPreformatted.Border
property.Highlight
, ClientHighlight
, and Unlink
properties to RichTextStyle
.RichTextStyle
properties aren't serialized if they're false.RichTextList.Elements
only accepts RichTextSection
s.RichTextList.Style
changed from a string to RichTextListStyle
enum.SlackException
's message.SlackFile
property to Image
element and ImageBlock
.Format
property to RichTextDate
.FileInput
block element.UseSlackNet
to delay responses until after handlers have completed.ChatApi.PostEphemeral
correctly returns PostEphemeralResponse
instead of PostMessageResponse
.SlackNet.AzureFunctions
package to properly support running in Azure Functions.Hosting a SlackNet application in Azure Functions is now properly supported with the new SlackNet.AzureFunctions package. Configuration is similar to previous Azure Functions integration with SlackNet.AspNetCore, but the APIs have been simplified, and the isolated worker model is now supported. Additionally, some issues around the function shutting down before a request has finished being handled have been resolved, albeit at the cost of dropping support for early responses (responses will be sent after you've finished handling the request, no matter how early you respond). See the readme and AzureFunctionsExample project for more information.
VerifyWith
, UseSigningSecret
, and UseEventUrlVerification
, called inside UseSlackNet
, have been marked as obsolete, and will be removed in a future release. These calls should now be made in AddSlackNet
instead.AddSlackNet
now takes in an AspNetSlackServiceConfiguration
instead of a ServiceCollectionSlackServiceConfiguration
. The API is otherwise compatible.Microsoft.AspNetCore.Http
and Microsoft.AspNetCore.Http.Abstractions
dependencies have been bumped to versions 2.1.22 and 2.1.1 respectively.ISlackRequestHandler
no longer take in a SlackEndpointConfiguration
. The configuration is now injected into the implementation.SlackResult
no longer implements IActionResult
.If you're currently using SlackNet.AspNetCore with Azure Functions, you'll need to switch to SlackNet.AzureFunctions, and make the following changes:
AddSlackNet
extension from SlackNet.AzureFunctions
.SlackEndpointConfiguration
configuration into AddSlackNet
, and remove its service collection registration.ISlackRequestHandler
and SlackEndpointConfiguration
from your endpoints class with just ISlackFunctionRequestHandler
, and update its usage to remove the second argument from each method call.Task<SlackResult>
to Task<SlackFunctionResult>
.See the AzureFunctionsExample project for an example.
Thankyou to @matthawley for his help with this release 💪
ExternalMultiSelectMenu
.Thankyou to @rzezak for this release 🐞🔨
View
property to BlockOptionsRequest
.includeAllMetadata
parameter to IConversationsApi.History
.cursor
and/or CancellationToken
to IConversationsApi.History
as positional arguments, you'll need to either add false
as the includeAllMetadata
argument, or specify the cursor
/cancellationToken
parameter names.Thankyou to @nimoskov for his help with this release ✨
teamId
parameter to IConversationsApi.Create
.MessageMetadataPosted
, MessageMetadataUpdated
, and MessageMetadataDeleted
events.BotId
, AppId
, and BotProfile
properties to MessageEvent
.TeamId
, Deleted
, and Updated
properties to BotInfo
.RichTextInput
and fixed posting messages with RichTextBlock
s.When posting a message to Slack, you can specify the metadata in one of two ways:
await slack.Chat.PostMessage(new Message
{
Channel = "#general",
Text = "My message",
// Use your own metadata object. It will be serialized with the standard Slack conventions,
// and the event_type will be the name of the class in snake case.
MetadataObject = new MyMetadata("my info"),
// Specify the metadata JSON explicitly. This will take precedence over MetadataObject.
MetadataJson = new MessageMetadata
{
EventType = "my_metadata",
EventPayload = JToken.Parse("""{ "custom_info": "my info" }""") // Get your JToken from wherever you like
}
});
Messages retrieved from Slack will have a Metadata
property that contains the event type and JSON as a JToken
. To deserialize the JSON using the standard Slack JSON conventions, use the ToObject
method on MessageMetadata
, not the ToObject
method on JToken
:
var myMetadata = message.Metadata.ToObject<MyMetadata>();
CancellationToken
to IConversationsApi.Create
as a positional argument, you'll need to either add null
as the teamId
argument, or specify the cancellationToken
parameter name.SlackJsonSettings
parameter to the ChatApi
constructor. If you're constructing ChatApi
manually, you can pass in Default.JsonSettings()
, or your own customized settings.InitialValue
property of TextInput
down to its sub-classes, to account for RichTextInput
's different type of value.Thankyou to @jtsai-osa for his help with this release 👍
SnoozeEndTime
on SnoozeResponse
and OwnDndResponse
so it deserializes properly.SnoozeIsIndefinite
to SnoozeResponse
and OwnDndResponse
.IsExtSharedChannel
property to EventCallback
.SlackNet.AspNetCore
.SlackNet.Error
instead of just SlackNet
).When using the default logger with ASP.NET, individual SlackNet log categories can be enabled in appsettings.json with:
"Logging": {
"LogLevel": {
"SlackNet.Data": "Trace",
"SlackNet.Serialization": "Trace",
"SlackNet.Internal": "Debug",
"SlackNet.Request": "Information",
"SlackNet.Error": "Error"
}
}
Setting a category to a higher level will filter out logs from that category.