Example: SQL report by e-mail
This is the campaign shape most teams need first: read rows from a database, do something for each one, on a schedule. Every part is a built-in step, so there is no code to maintain — only one query and one e-mail template.
- Chain a SQL step, a loop and a Send email step
- Bind each row’s fields into a template
Three steps, no script
The SQL step’s output is { rows, … }. A loop bound to it iterates the rows; inside the loop, item is the current row, so the e-mail step binds item.email as the recipient and item.name and item.total as template values.
Build it
- Add the SQL step
Press + under Start, choose PostgreSQL, pick the connection and paste the query below.
- Add a loop over its rows
Below it add a Loop, bind its list to the SQL step’s output and set it to parallel with 3 at a time.
- Send one e-mail per row
Inside the loop add Send email: choose a published template that uses
{{name}}and{{total}}, bind Recipients toitem.emailand each template value to the row’s field. - Run it, then schedule it
Run the flow and check the iterations; then publish it and add a schedule in the Triggers tab, for example every weekday at 08:00.
SELECT c.name, c.email, o.total
FROM orders o
JOIN customers c ON c.id = o.customer_id
WHERE o.status = 'late'
ORDER BY o.created_at{
"ok": true,
"historyId": "7c1e…",
"to": [
"bruno@example.test"
],
"subject": "Your order is late, Bruno Lima"
}Before it goes live
Send to yourself first: replace the recipient binding with your own address, run, and read the e-mails. A loop iteration that fails does not stop the others when the step is set to continue on error, and an alert rule tells you when a scheduled run fails.