SlackAPIFileOperator

Slack

Send a file to a slack channels Examples:

View on GitHub

Last Updated: Oct. 23, 2022

Access Instructions

Install the Slack provider package into your Airflow environment.

Import the module into your DAG file and instantiate it with your desired params.

Parameters

channelsComma-separated list of channel names or IDs where the file will be shared. If set this argument to None, then file will send to associated workspace. (templated)
initial_commentmessage to send to slack. (templated)
filenamename of the file (templated)
filetypeslack filetype. (templated) See: https://api.slack.com/types/file#file_types
contentfile content. (templated)
titletitle of file. (templated)
channel(deprecated) channel in which to sent file on slack name

Documentation

Send a file to a slack channels Examples:

# Send file with filename and filetype
slack_operator_file = SlackAPIFileOperator(
task_id="slack_file_upload_1",
dag=dag,
slack_conn_id="slack",
channels="#general,#random",
initial_comment="Hello World!",
filename="/files/dags/test.txt",
filetype="txt",
)
# Send file content
slack_operator_file_content = SlackAPIFileOperator(
task_id="slack_file_upload_2",
dag=dag,
slack_conn_id="slack",
channels="#general",
initial_comment="Hello World!",
content="file content in txt",
)

Was this page helpful?