Skip to content

v0.7.0

Compare
Choose a tag to compare
@soxtoby soxtoby released this 16 May 02:16
· 275 commits to master since this release
  • Added global shortcut support.
  • Fixed an issue deserializing large requests.
  • More consistent handler registration.
  • Added ability to replace the root handlers.
  • Simplified Azure Functions integration a little.
  • Experimental early-response API.

Breaking Changes

  • MessageAction, IMessageActionHandler, and RegisterMessageActionHandler have been renamed to MessageShortcut, IMessageShortcutHandler, and RegisterMessageShortcutHandler respectively, to match Slack's new terminology. The old types & methods are still available, but have been marked as Obsolete.
  • All the base handler registration classes (e.g. SlackEvents and SlackBlockActions) have been removed. If you were using any of these, I'd recommend just copying their old code - they were pretty simple.
    • If you were relying on the IObservables exposed by SlackEvents, and you're using SlackNet.AspNetCore, you can inject IEventsObservables, which exposes the same observables.
  • RegisterDialogSubmissionHandler now takes in a callbackId, so you can register different handlers for different dialogs. If you want the old behavior where one handler is used for all dialogs, use ReplaceLegacyDialogSubmissionHandling instead. Note that this is for Slack's old dialogs - I'd recommend moving to modal views going forward.
  • SlackResponse has been renamed to SlackResult, and now implements IActionResult.
    • SlackNet.AspNetCore now depends on Microsoft.AspNetCore.Mvc.Abstractions, which you're probably already depending on.
    • If you're using SlackNet.AspNetCore with Azure Functions, I'd recommend copying the updated SlackEndpoints example - it's much simpler now.

Experimental early-response API

A common issue with the current handler API is that SlackNet waits for all of the handlers' work to complete before responding to Slack, which doesn't wait very long before showing errors in the UI. This release includes an experimental API for responding to Slack before completing all the work a handler performs. This lets you implement a handler like this:

public Task Handle(SlashCommand command, Responder<SlashCommandResponse> respond)
{
    // Provides feedback as quickly as possible
    await respond(new SlashCommandResponse { Message = new Message { 
        Text = "Command received" } });

    // Posts more information once it's available
    var info = await FetchSomeInfoFromARemoteService();
    await _slackApi.Chat.PostMessage(new Message { 
        Text = $"Here's what you asked for: {info}" });
}

These new handler types can be registered with the RegisterAsync* methods available inside the configuration callback of AddSlackNet(). Work performed after responding should probably still be kept fairly short, in the order of seconds. If you want to perform longer operations, it's probably best to do it in a background thread.

Please give this a go and provide feedback in the early-response feedback issue.