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 .md to any kestra.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_csv
namespace: company.team
tasks:
- id: download
type: io.kestra.plugin.core.http.Download
uri: https://huggingface.co/datasets/kestra/datasets/raw/main/csv/orders.csv

Option 1: send the file as a Slack attachment

Create a Slack App with a bot token

  1. Go to the Slack API website and create a new app “From scratch”.
  2. Under OAuth & Permissions, add the files:write Bot Token Scope (add chat:write too if you also want to post a message).
  3. Install the app to your workspace and copy the Bot User OAuth Token (starts with xoxb-).
  4. Invite the bot to the target channel: /invite @your-app-name.
  5. 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_slack
namespace: 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:"

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

  1. Enable 2-Step Verification on the Google account, if not already enabled.
  2. Go to myaccount.google.com/apppasswords, create a new app password (e.g. named “Kestra”).
  3. Store the generated 16-character password as a Kestra Secret called GMAIL_APP_PASSWORD.

Send the file as an attachment

id: send_report_by_email
namespace: 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/csv

Combine 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_export
namespace: 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?