Skip to main content

PublishSlack

Description

Posts a message to the specified Slack channel. The content of the message can be either a user-defined message that makes use of Expression Language or the contents of the FlowFile can be sent as the message. If sending a user-defined message, the contents of the FlowFile may also be optionally uploaded as a file attachment.

Tags

chat.postMessage, conversation, publish, send, slack, social media, team, text, unstructured, upload, write

Properties

In the list below required Properties are shown with an asterisk (*). Other properties are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

Display NameAPI NameDefault ValueAllowable ValuesDescription
Access Token *Access TokenOAuth Access Token used for authenticating/authorizing the Slack request sent by NiFi. This may be either a User Token or a Bot Token. The token must be granted the chat:write scope. Additionally, in order to upload FlowFile contents as an attachment, it must be granted files:write.
Channel *ChannelThe name or identifier of the channel to send the message to. If using a channel name, it must be prefixed with the # character. For example, #general. This is valid only for public channels. Otherwise, the unique identifier of the channel to publish to must be provided.

Supports Expression Language, using FlowFile attributes and Environment variables.
Publish Strategy *Publish StrategySend FlowFile Content as Message
  • Send FlowFile Content as Message
  • Use 'Message Text' Property
Specifies how the Processor will send the message or file to Slack.
Message Text *Message TextThe text of the message to send to Slack.

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Publish Strategy has a value of Use 'Message Text' Property
Character Set *Character SetUTF-8Specifies the name of the Character Set used to encode the FlowFile contents.

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Publish Strategy has a value of Send FlowFile Content as Message
Include FlowFile Content as Attachment *Include FlowFile Content as Attachmentfalse
  • true
  • false
Specifies whether or not the contents of the FlowFile should be uploaded as an attachment to the Slack message.

This property is only considered if:
  • the property Publish Strategy has a value of Use 'Message Text' Property
Max FlowFile Size *Max FlowFile Size1 MBThe maximum size of a FlowFile that can be sent to Slack. If any FlowFile exceeds this size, it will be routed to failure. This plays an important role because the entire contents of the file must be loaded into NiFi's heap in order to send the data to Slack.

This property is only considered if:
  • the property Include FlowFile Content as Attachment has a value of true
Thread TimestampThread TimestampThe Timestamp identifier for the thread that this message is to be a part of. If not specified, the message will be a top-level message instead of being in a thread.

Supports Expression Language, using FlowFile attributes and Environment variables.

Dynamic Properties

This component does not support dynamic properties.

Relationships

NameDescription
failureFlowFiles are routed to 'failure' if unable to be sent to Slack for any other reason
rate limitedFlowFiles are routed to 'rate limited' if the Rate Limit has been exceeded
successFlowFiles are routed to success after being successfully sent to Slack

Reads Attributes

This processor does not read attributes.

Writes Attributes

NameDescription
slack.channel.idThe ID of the Slack Channel from which the messages were retrieved
slack.tsThe timestamp of the slack messages that was sent; this is used by Slack as a unique identifier

State Management

This component does not store state.

Restricted

This component is not restricted.

Input Requirement

This component requires an incoming relationship.

Example Use Cases

Use Case 1

Send specific text as a message to Slack, optionally including the FlowFile's contents as an attached file.

Configuration

Set "Access Token" to the value of your Slack OAuth Access Token.
Set "Channel" to the ID of the channel or the name of the channel prefixed with the # symbol. For example, "C0123456789" or "#general".
Set "Publish Strategy" to "Use 'Message Text' Property".
Set "Message Text" to the text that you would like to send as the Slack message.
Set "Include FlowFile Content as Attachment" to "true" if the FlowFile's contents should be attached as a file, or "false" to send just the message text without an attachment.

Use Case 2

Send the contents of the FlowFile as a message to Slack.

Configuration

Set "Access Token" to the value of your Slack OAuth Access Token.
Set "Channel" to the ID of the channel or the name of the channel prefixed with the # symbol. For example, "C0123456789" or "#general".
Set "Publish Strategy" to "Send FlowFile Content as Message".

Example Use Cases Involving Other Components

Multiprocessor Use Case 1

Respond to a Slack message in a thread.

Components Involved

  • EvaluateJsonPath
    1. Set "Destination" to "flowfile-attribute"
    2. Add a new property named "thread.ts" with a value of $.threadTs
    3. Add a new property named "message.ts" with a value of $.ts
    4. Add a new property named "channel.id" with a value of $.channel
    5. Add a new property named "user.id" with a value of $.user
    6. Connect the "matched" Relationship to PublishSlack.
  • PublishSlack
    1. Set "Access Token" to the value of your Slack OAuth Access Token.
    2. Set "Channel" to ${'channel.id'}
    3. Set "Publish Strategy" to "Use 'Message Text' Property".
    4. Set "Message Text" to the text that you would like to send as the response. If desired, you can reference the user of the original message by including the text <@$\{'user.id'}>.
    5. For example: Hey, <@$\{'user.id'}>, thanks for asking...
    6. Set "Include FlowFile Content as Attachment" to "false".
    7. Set "Thread Timestamp" to ${'thread.ts':replaceEmpty( $\{'message.ts'} )}

System Resource Considerations

This component does not specify system resource considerations.

See Also

ConsumeSlack, ListenSlack