Apify Actor Run Failure Sentinel
Audit an Apify actor's most recent run status, alert Slack when it failed, timed out, or was aborted, and optionally launch a fresh retry run under a cost cap.
Pull Salesforce records into Postgres on a schedule with Kestra. Watermarked incremental loads, idempotent upserts, and no Enterprise plugin required.
Most Salesforce extracts fail in one of two ways: they re-read the entire object on every run, or they insert rather than upsert and quietly fill the warehouse with duplicates. This blueprint does neither. It keeps a high-water mark in Kestra's KV Store, asks Salesforce only for records modified since that mark, and loads them with a batched INSERT ... ON CONFLICT DO UPDATE keyed on the Salesforce record id. It also uses only the open-source HTTP and JDBC plugins, so no Enterprise-tier Salesforce plugin is required.
every_fifteen_minutes trigger (io.kestra.plugin.core.trigger.Schedule) starts the flow. It ships disabled so adding the blueprint never surprises you with traffic against your org.read_watermark (io.kestra.plugin.core.kv.Get) loads the newest LastModifiedDate from the previous successful run. errorOnMissing: false means the first run starts from scratch rather than failing.get_access_token exchanges a Connected App's client id and secret for an access token using the OAuth 2.0 client credentials grant, so the flow authenticates as a service and needs no interactive login.query_salesforce runs a SOQL query filtered on LastModifiedDate > watermark, ordered ascending and capped by batch_limit.has_new_records (io.kestra.plugin.core.flow.If) branches on totalSize. With nothing to do, the flow logs and exits rather than touching the database.write_records and to_ion stage the response as a file and convert it to Kestra's internal ION format, so the load streams instead of holding every record in the execution context.load_batch (io.kestra.plugin.jdbc.postgresql.Batch) performs one batched upsert with bound parameters.save_watermark advances the mark only after the load succeeds.errors block reports a failure and states explicitly that the watermark did not move.A cron'd script can call the Salesforce API, but it has nowhere durable to keep a watermark, no execution history when numbers look wrong, and no safe behaviour when a load half-fails. Kestra supplies the KV Store for cross-run state, a per-execution audit trail, retries, and an error path that tells an operator whether data was lost. The ordering guarantee that matters here, advancing the watermark only after a successful write, is expressed directly in the task graph.
A Salesforce org with an External Client App (or Connected App) configured for the OAuth client credentials flow, with a Run As user set.
A reachable PostgreSQL database.
A destination table. The default schema is:
CREATE TABLE IF NOT EXISTS sf_opportunity (
id TEXT PRIMARY KEY,
name TEXT,
stage_name TEXT,
amount NUMERIC,
close_date DATE,
account_id TEXT,
last_modified_date TIMESTAMPTZ,
synced_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
SF_DOMAIN: your Salesforce instance URL, including the scheme, for example https://example.my.salesforce.com.SF_CLIENT_ID: Consumer Key of the Connected or External Client App.SF_CLIENT_SECRET: Consumer Secret of that app.POSTGRES_URL: JDBC URL of the destination database, for example jdbc:postgresql://postgres:5432/analytics.POSTGRES_USERNAME: Postgres user with insert and update rights on the target table.POSTGRES_PASSWORD: that user's password.batch_limit records.else branch and report nothing to sync.every_fifteen_minutes trigger once you are satisfied with the cadence.sobject and fields at Account, Case, or Lead, and adjust the columns list and target table to match. Running it once per object gives you one table each, joinable on the foreign keys Salesforce already returns: SELECT o.name, a.name FROM sf_opportunity o LEFT JOIN sf_account a ON a.id = o.account_id.batch_limit toward 2000. Above that the SOQL response paginates and you would need to follow nextRecordsUrl, which this flow does not do; for very large extracts use the Salesforce Bulk API 2.0 instead./services/data/v62.0/sobjects/{sobject}/deleted and soft-deleting the matching rows.io.kestra.plugin.core.flow.Switch after the load to notify a channel when high-value records change stage.