Skip to content
NEWMeet Alaaddin, your AI genie with a voice. trig8n launches 1 January 2027. See what is new

Library / AI Agents & Assistants

AI Agents & Assistants

Monitor competitor price shifts with Apify, Postgres, OpenAI, and Slack

On a schedule, it runs an AI agent with OpenAI / ChatGPT using Apify, Postgres, Slack.

What it does

## Run this SQL first The workflow queries pricing.price_history and pricing.price_moves_today. They do not exist until you run this, and the first execution fails with relation "pricing.price_history" does not exist without it. Needs Postgres 15 or later. On Supabase, paste it into the SQL editor and run once. It puts everything in a private schema with RLS on and the anon and authenticated roles revoked, so on Supabase the table is never reachable through the Data API. sql -- Requires Postgres 15 or later, which Supabase satisfies. The views use -- Run once before importing the n8n workflow. create schema if not exists pricing; create table if not exists pricing.price_history ( id bigserial primary key, captured_at timestamptz not null default now(), capture_date date not null default (now()::date), sku_key text not null, -- stable identity you track on; the canonical product URL by default product_url text not null, retailer text, -- hostname, e.g. amazon.com product_name text, brand text, price numeric(12,2), currency text, -- ISO 4217, e.g. USD; the workflow maps symbols before writing in_stock boolean, -- null means the source did not report availability image_url text, raw jsonb -- full Actor output, so you can backfill new columns later ); -- point: no policy means no access. n8n connects as the table owner or as alter table pricing.price_history enable row level security; -- Supabase ships the anon and authenticated roles. Plain Postgres does not, do $$ begin if exists (select 1 from pg_roles where rolname = 'anon') then revoke all on schema pricing from anon, authenticated; revoke all on all tables in schema pricing from anon, authenticated; revoke all on all sequences in schema pricing from anon, authenticated; alter default privileges in schema pricing revoke all on tables from anon, authenticated; end if; end $$; -- One row per SKU per day. Re-running the workflow the same day updates instead of duplicating. create unique index if not exists price_history_sku_day on pricing.price_history (sku_key, capture_date); create index if not exists price_history_sku_time on pricing.price_history (sku_key, captured_at desc); create or replace view pricing.price_baseline with (security_invoker = true) as select sku_key, max(retailer) as retailer, count(*) filter (where capture_date = current_date - interval '30 days') as observations_30d, min(capture_date)

The steps

  1. Every Morning at 6am
  2. Select Pages to Monitor
  3. Run Apify Scraper
  4. Normalize Product Data
  5. Save Daily Snapshot to DB
  6. Detect Price Changes
  7. Collect Price Changes
  8. Repricing Analysis Agent
  9. Chat Model
  10. Send Slack Alert
  11. Check Data Integrity
  12. Send Slack Warning

Similar automations