Extract Data via HTTP and Send It as a Slack or Email Attachment
For the complete documentation index, see llms.txt. For a full content snapshot, see llms-full.txt. Append.mdto anykestra.io/docs/*URL for plain Markdown.
Extract a file from any HTTP source and deliver it straight to your team, either as a Slack attachment or as an email attachment.
A common pattern is to download a report or export from an external system and forward it to stakeholders without storing it anywhere in between. This guide shows both delivery options starting from the same Download task.
Download the file over HTTP
The io.kestra.plugin.core.http.Download task fetches the file and stores it in Kestra’s internal storage. Every following task references it via {{ outputs.download.uri }}.
id: download_orders_csvnamespace: company.team
tasks: - id: download type: io.kestra.plugin.core.http.Download uri: https://huggingface.co/datasets/kestra/datasets/raw/main/csv/orders.csvOption 1: send the file as a Slack attachment
SlackIncomingWebhook cannot send file attachments — that’s a Slack API limitation, incoming webhooks only accept a JSON payload and don’t support the files.upload endpoint. To attach a file, you need a Slack App with a bot token instead.
Create a Slack App with a bot token
- Go to the Slack API website and create a new app “From scratch”.
- Under OAuth & Permissions, add the
files:writeBot Token Scope (addchat:writetoo if you also want to post a message). - Install the app to your workspace and copy the Bot User OAuth Token (starts with
xoxb-). - Invite the bot to the target channel:
/invite @your-app-name. - Store the token as a Kestra Secret called
SLACK_TOKEN.
Upload the file to a channel
Use the io.kestra.plugin.slack.app.files.Upload task, with initialComment to attach a message to the file in the same call:
id: send_report_to_slacknamespace: company.team
tasks: - id: download type: io.kestra.plugin.core.http.Download uri: https://huggingface.co/datasets/kestra/datasets/raw/main/csv/orders.csv
- id: upload_to_slack type: io.kestra.plugin.slack.app.files.Upload token: "{{ secret('SLACK_TOKEN') }}" channels: ["#reports"] from: "{{ outputs.download.uri }}" filename: "orders.csv" title: "Daily orders export" initialComment: "Here is today's orders export :point_down:"initialComment requires a recent version of the Slack plugin. On older versions, post a message with io.kestra.plugin.slack.app.chats.Post to the same channel before running Upload instead.
Option 2: send the file as an email attachment via Gmail
Gmail’s SMTP server accepts an App Password once 2-Step Verification is enabled on the account. Use it with the io.kestra.plugin.email.MailSend task.
Create a Gmail App Password
- Enable 2-Step Verification on the Google account, if not already enabled.
- Go to myaccount.google.com/apppasswords, create a new app password (e.g. named “Kestra”).
- Store the generated 16-character password as a Kestra Secret called
GMAIL_APP_PASSWORD.
Send the file as an attachment
id: send_report_by_emailnamespace: company.team
tasks: - id: download type: io.kestra.plugin.core.http.Download uri: https://huggingface.co/datasets/kestra/datasets/raw/main/csv/orders.csv
- id: send_email type: io.kestra.plugin.email.MailSend host: smtp.gmail.com port: 587 transportStrategy: SMTP_TLS username: "{{ secret('GMAIL_ADDRESS') }}" password: "{{ secret('GMAIL_APP_PASSWORD') }}" from: "{{ secret('GMAIL_ADDRESS') }}" to: team@company.com subject: "Daily orders export" htmlTextContent: "Please find today's orders export attached." attachments: - name: orders.csv uri: "{{ outputs.download.uri }}" contentType: text/csvCombine both in a single flow
Both delivery paths read from the same download output, so nothing stops you from running them side by side in one flow:
id: distribute_orders_exportnamespace: company.team
tasks: - id: download type: io.kestra.plugin.core.http.Download uri: https://huggingface.co/datasets/kestra/datasets/raw/main/csv/orders.csv
- id: upload_to_slack type: io.kestra.plugin.slack.app.files.Upload token: "{{ secret('SLACK_TOKEN') }}" channels: ["#reports"] from: "{{ outputs.download.uri }}" filename: "orders.csv" title: "Daily orders export" initialComment: "Here is today's orders export :point_down:"
- id: send_email type: io.kestra.plugin.email.MailSend host: smtp.gmail.com port: 587 transportStrategy: SMTP_TLS username: "{{ secret('GMAIL_ADDRESS') }}" password: "{{ secret('GMAIL_APP_PASSWORD') }}" from: "{{ secret('GMAIL_ADDRESS') }}" to: team@company.com subject: "Daily orders export" htmlTextContent: "Please find today's orders export attached." attachments: - name: orders.csv uri: "{{ outputs.download.uri }}" contentType: text/csv
triggers: - id: daily type: io.kestra.plugin.core.trigger.Schedule cron: "0 8 * * *"Was this page helpful?