Skip to content

v0.11.3

Compare
Choose a tag to compare
@soxtoby soxtoby released this 07 Oct 02:18
· 48 commits to master since this release
  • Added optional teamId parameter to IConversationsApi.Create.
  • Added support for message metadata.
  • Added MessageMetadataPosted, MessageMetadataUpdated, and MessageMetadataDeleted events.
  • Added BotId, AppId, and BotProfile properties to MessageEvent.
  • Added TeamId, Deleted, and Updated properties to BotInfo.
  • Added RichTextInput and fixed posting messages with RichTextBlocks.

Metadata

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>();

Potentially breaking changes

  • If you were passing a 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.
  • Added a SlackJsonSettings parameter to the ChatApi constructor. If you're constructing ChatApi manually, you can pass in Default.JsonSettings(), or your own customized settings.
  • Pushed the 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 👍