Send the report. Skip the routine.
Count yesterday’s orders in PostgreSQL and email the total through SendGrid every 24 hours.
THE FLOW
From trigger to outcome.
A repeatable report with its source data, delivery result, and run history attached.
- 01 →
Schedule
Start on a repeating 24-hour interval, or run manually to test the report.
- 02 →
Collect
Query the orders table and select the count from .rows[0].orders.
- 03 →
Publish
Send the total to your team using a configured SendGrid sender.
USE THIS RECIPE
Your workflow,
in YAML.
- Create DATABASE_DSN for a PostgreSQL database with an orders table and a created_at column, or adapt the query to your schema.
- Create SENDGRID_API_KEY, then replace from and to with your verified sender and recipient.
- Check the database session timezone: CURRENT_DATE defines yesterday in that timezone.
Copy or download the manifest, configure your values, and add it through Workflows or your AI workspace. Opening the console does not create or enable a workflow.
- Query databases
- Transform JSON
- Send email
workflow_id: daily-report
title: Daily order report
enabled: true
triggers:
- type: schedule
interval: 24h
steps:
- step_id: report
kind: sql
command:
driver: postgres
dsn: secret://DATABASE_DSN
query: |
SELECT COUNT(*) AS orders
FROM orders
WHERE created_at >= CURRENT_DATE - INTERVAL '1 day'
AND created_at < CURRENT_DATE
- step_id: count
kind: data-json
dependencies: [report]
command:
from_step: report
path: .rows[0].orders
- step_id: send
kind: email
dependencies: [count]
command:
provider: sendgrid
api_key: secret://SENDGRID_API_KEY
from: reports@example.com
to: team@example.com
subject: Yesterday's orders
text: "Orders received: {{ .steps.count.value }}"
Setup Use a PostgreSQL database with an orders table and created_at column. Configure DATABASE_DSN, SENDGRID_API_KEY, a verified sender, and your recipient. This runs at a 24-hour interval, not a fixed time of day.
EXPECTED RESULT
Know what to look for.
For 12 orders yesterday, the count step returns 12 and the email text is "Orders received: 12". A successful send means the provider accepted the request; check the provider for final delivery.
This is an interval schedule, not a fixed 8 AM job. The first scheduler check can start a run immediately, and restarting the scheduler resets its interval tracking. Use an external scheduler with a webhook for a fixed local time.
TEST YOUR SETUP
Check a complete run.
- Remove triggers for a manual-only test, then restore the interval when delivery is ready.
- Test a day with no orders: the count should be 0. Also check database and email-provider failures.
- If duplicate reports matter, track the reporting date at your destination. The scheduler does not enforce concurrency: forbid.
Adapt this recipe with your AI agent
Adapt this Adios scheduled-report YAML to my database schema and recipient. Use a schedule trigger with interval: 24h, a PostgreSQL sql step, data-json to select the count, and a SendGrid email step. Use DATABASE_DSN and SENDGRID_API_KEY secret references. Explain the database timezone, interval timing, and duplicate-report behavior. Show the changes and test with sample data before enabling the schedule or sending real email.
KEEP CONNECTING