Three destinations, three ways in
| Destination | How you send | What you must set up |
|---|---|---|
| Slack | POST JSON to an incoming webhook URL | A Slack app with Incoming Webhooks turned on, one webhook per channel |
| SMTP, or a mail provider API | A sending domain, credentials and a verified sender | |
| Google Sheets | Sheets API, authenticated by a service account | A Google Cloud project with the Sheets API on, a service account key, and the spreadsheet shared with it |
In all three the query part is the same: run SQL, get rows, turn rows into something the destination understands. The work is in the last step.
Slack: incoming webhooks
You create a Slack app, turn on Incoming Webhooks and add a webhook to the workspace. Slack asks which channel it may post to. That choice is fixed: a webhook is tied to one channel, and the payload cannot override it. To reach two channels, create two webhooks.
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"Open orders: 14"}' \
https://hooks.slack.com/services/T000/B000/XXXXThe JSON must carry a text field, or the call fails with no_text. You can add blocks for richer layouts. The webhook URL works as a credential, so keep it out of public repositories. Slack searches for leaked webhook URLs and revokes them.
A webhook posts text. It does not upload files. If you want the CSV or Excel file itself in Slack, the app needs a bot token with the files:write scope and a channel id. Slack documents the file upload flow on its messaging pages.
E-mail: SMTP and sending reputation
Sending e-mail from a script means an SMTP server or a provider API, a sender address and a domain whose SPF and DKIM records are set. Without those, reports land in spam, and the first time a manager says "I never got it" is the day you learn this.
- Send from a domain you control and authenticate it.
- Keep the table short in the body, and put anything long in an attachment.
- Use a clear subject that carries the date or period, so the inbox search works.
- Handle bounces: an address that hard-bounces should stop being retried.
Attachment size limits come from the receiving mail server, not from your script, and they differ by provider. Check the limits of the providers your readers use before you schedule a large file.
Google Sheets: the Sheets API
A spreadsheet is the right destination when people will keep working with the rows, or when another tool reads from the sheet. You enable the Google Sheets API on a Google Cloud project, create a service account, download its JSON key, and share the spreadsheet with the service account address as Editor. Skip that last step and every call fails with 403.
Two modes cover most cases. Replace the tab on every run, so the sheet always shows the latest result. Or append rows under the existing ones, to build a log over time.
The API has per-minute quotas. At the time of writing, Google lists 300 read and 300 write requests per minute per project, and 60 of each per user per project, and it answers over-quota calls with HTTP 429. Write the rows in one request rather than one per row, and back off when you get a 429.
Table in the message, or a file attached
| Format | Best for | Watch out for |
|---|---|---|
| Inline table | A handful of rows read on a phone | Long tables wrap badly and get clipped |
| CSV | Another system will read it, or the volume is large | Excel guesses separators and encoding |
| XLSX | The reader filters, sums and pastes | Needs a library to build, and a slower open on big files |
| A document that must look the same for all | Not editable, so not for people who want to work on the numbers | |
| Sheet tab | A shared, living table | API quotas, and the sheet is only as private as its sharing |
A rule of thumb: if the answer fits in ten rows, put it in the message. If someone will sort it, attach a file or write a sheet.
Alerts: send only when a row matches
A report goes out every time. An alert goes out only when the data says so. The difference is what keeps a Slack channel readable. Write the condition into the query, so an empty result means "all good", and skip the send when the result is empty.
SELECT id, customer, total, due_dateFROM invoicesWHERE status = 'open' AND due_date < current_date - 7ORDER BY due_dateLIMIT 50;With that query on a daily schedule and an "skip when empty" rule, the channel stays quiet on good days. A row count threshold is a second option: send only when more than ten rows come back.
How DataRunner does each
DataRunner has seven delivery channels: e-mail, Slack, WhatsApp (beta), Telegram, Discord, signed webhook and Google Sheets. The formats are CSV, Excel, PDF and inline HTML.
- Slack: you paste the incoming webhook URL. A report arrives as a message with the summary. To attach the CSV or Excel file, add a bot token with files:write and put the channel id in the target.
- E-mail: it sends through the SMTP or Resend provider configured for the workspace, from a verified domain of yours. Bounced addresses go on a suppression list and are not retried.
- Google Sheets: you paste the service account JSON and the spreadsheet link, share the sheet with the service account as Editor, and name the tab. Each run replaces the tab, and adding |append to the tab name appends rows under the existing ones.
- Rules: skip the send when the result is empty, send only above a row count, or escalate to another channel past a threshold.
- Limits: the row ceiling comes from the plan. When a run reaches it, the run stops and the report is marked truncated instead of delivering half a set silently.
- Add the channel under Channels and press Test. It validates the credentials against the provider.
- Open the report and choose the destination under Destinations.
- Pick the format and the delivery rule.
- Set the schedule and its time zone, then run it once to see the delivery in the run log.
Test confirms credentials. The run log is where you confirm that a real delivery reached each recipient and what the provider answered.