New to Kestra?
Use blueprints to kickstart your first workflows.
Run a daily DocumentDB aggregation pipeline in Kestra, export the grouped result to CSV, and post a Slack digest with real per-status revenue figures.
Turn raw DocumentDB orders into a daily, decision-ready summary without writing a line of glue code. This blueprint runs a MongoDB-style aggregation pipeline against a DocumentDB orders collection, stores the grouped result in Kestra internal storage, converts it to a CSV report, and posts a Slack digest with the actual per-status order counts and revenue. It is a read-only analytics pattern (no documents are modified) and the reporting window is derived from the scheduled date rather than now(), so backfills and missed-run replays always report the correct day. Keywords: DocumentDB aggregation pipeline, daily orders report, CSV export, Slack digest, scheduled analytics, backfill-safe reporting.
daily_report Schedule trigger (io.kestra.plugin.core.trigger.Schedule) fires every day at 07:00 UTC via cron 0 7 * * *.aggregate_orders task (io.kestra.plugin.documentdb.Read) runs an aggregationPipeline that $matches the previous UTC calendar day, $groups by status, sums orders and revenue, and $sorts by revenue. The window is bound to {{ trigger.date ?? execution.startDate }} and the created_at filter uses the EJSON $date form so it compares against a real BSON date. With fetchType: STORE, the result is written to internal storage as Ion.to_csv task (io.kestra.plugin.serdes.csv.IonToCsv) converts that Ion result into a downloadable CSV with header: true.fetch_groups task re-reads the same aggregation with fetchType: FETCH so the digest can surface in-memory rows.report task (io.kestra.plugin.core.flow.If) branches on {{ (outputs.fetch_groups.size ?? 0) > 0 }}: notify_digest posts a Slack Block Kit digest of each status with its order count and revenue plus a CSV link, while notify_empty posts a distinct no-orders message so a quiet day is never mistaken for a broken pipeline.errors handler (alert_failure) posts a Slack alert if any step fails, and every remote call retries three times at a 10s interval.DocumentDB has no built-in scheduler, no retry semantics, and no way to fan a query result out to CSV and Slack. Kestra adds the event and schedule triggers, automatic retries on every remote call, full execution lineage across the read, transform, and notify steps, and a declarative YAML definition you can version and review. The branching If and errors handler give you the operational guardrails a raw query cannot.
orders collection containing status, amount, and a date-typed created_at field (indexing created_at keeps the window query fast).created_at is stored as a BSON/EJSON date. If it is a string, migrate the field or change the $match to compare against an ISO string in your documents' format, since a type mismatch silently returns zero rows.DOCUMENTDB_HOST: base HTTPS endpoint of the DocumentDB Data REST API.DOCUMENTDB_USERNAME: basic-auth username for the DocumentDB API.DOCUMENTDB_PASSWORD: basic-auth password for the DocumentDB API.SLACK_WEBHOOK: Slack incoming webhook URL used to post the digest and failure alerts.database and collection variables at your orders data.$group key from status to region, channel, or product for a different cut of the data.IonToCsv or a Parquet/JSON serde and push the file to S3, GCS, or a data warehouse.