SlackChatProvider.

PostMessage(string, string, ICollection<SlackChatMessageAttachment>, SlackChatMessageSettings) Method

Summary

Post message to Slack Channel
Assembly
Cake.Slack.dll
Namespace
Cake.Slack.Chat
Containing Type
SlackChatProvider

Syntax

public SlackChatMessageResult PostMessage(string channel, string text, ICollection<SlackChatMessageAttachment> messageAttachments, SlackChatMessageSettings messageSettings)

Examples

     Information("Sending message to Slack...");

     var settings = new SlackChatMessageSettings { Token = "token" };
     var postMessageResult = Slack.Chat.PostMessage(
         "Cake",
         "It's not a party without Cake!",
         new new [] { new SlackChatMessageAttachment() },
         settings
         );

     if(postMessageResult.Ok)
     {
         Information("Message {0} successfully sent.", postMessageResult.TimeStamp);
     }
     else
     {
         Error("Failed to send message: {0}.", postMessageResult.Error);
     }

Attributes

Type Description
CakeAliasCategoryAttribute

Parameters

Name Type Description
channel string Channel to send message to. Can be a public channel, private group or IM channel. Can be an encoded ID, or a name.
text string Text of the message to send. For message formatting see Formatting | Slack
messageAttachments ICollection<SlackChatMessageAttachment> Lets you send a message attachment see Attachments | Slack
messageSettings SlackChatMessageSettings Lets you override default settings like UserName, IconUrl or if it should ThrowOnFail

Return Value

Type Description
SlackChatMessageResult Returns success/error/timestamp SlackChatMessageResult