HeyReach / LinkedIn export ingest (raw JSON → Supabase)
This is the minimal “land it somewhere durable” path for HeyReach MCP export JSON so it can be used later for training data prep and analytics.
Where it lands
- Supabase project: Brainforge Internal / platform (env:
BF_SUPABASE_URL,BF_SUPABASE_SERVICE_KEY) - Table:
heyreach_linkedin_export_raw(append-only; service-role writes only) - Migration:
apps/platform/supabase/migrations/014_heyreach_linkedin_export_raw.sql
One-time setup
- Apply the migration
apps/platform/supabase/migrations/014_heyreach_linkedin_export_raw.sqlto the BF internal Supabase project. - Ensure the uploader has
BF_SUPABASE_URL+BF_SUPABASE_SERVICE_KEYavailable in their environment.
Ingest an export
Scheduled export (HeyReach API)
If we store the HeyReach API key in 1Password, we can export on a schedule and write directly into Supabase (no manual file download needed).
This uses the HeyReach n8n-style API surface (base https://api.heyreach.io/api/n8n + header X-N8N-KEY) to pull:
- LinkedIn accounts (
POST /li_account/GetAll) - Inbox conversations (
POST /inbox/GetConversations) - Chatrooms/messages (
GET /inbox/GetChatroom/{accountId}/{conversationId})
Run it (1Password-injected env is recommended):
op run --env-file .env.local -- \
node scripts/export-heyreach-conversations.mjs --since "2026-04-10T00:00:00Z"Dry run (fetch + build hash, no Supabase write):
op run --env-file .env.local -- node scripts/export-heyreach-conversations.mjs --dry-runRailway cron setup
Recommended: deploy as a separate Railway cron service so we don’t couple this job to the Platform (Next.js) build.
Service root directory:
apps/heyreach-export
Build:
npm install(only)
Start:
npm run start
Schedule: 6:00am ET daily
Railway cron is UTC, so:
- During EDT (UTC-4):
0 10 * * * - During EST (UTC-5):
0 11 * * *
If you want it pinned to 6:00am ET year-round, update the cron expression at DST boundaries.
If you instead want to run it inside the Platform service, Railway can run the Platform wrapper so the command is stable regardless of service working directory:
node tasks/export-heyreach-conversations.jsRequired Railway variables on the cron service:
HEYREACH_API_KEYBF_SUPABASE_URLBF_SUPABASE_SERVICE_KEY(orBF_SUPABASE_SERVICE_ROLE_KEY)
Suggested schedule:
- Daily, off-hours (Railway cron uses UTC)
Manual export (JSON file → Supabase)
node scripts/ingest-heyreach-export.mjs --file /path/to/heyreach-export.json \
--name "HeyReach export (Gov outbound) 2026-04-10" \
--exported-at "2026-04-10T12:34:56Z" \
--uploaded-by "robert@brainforge.ai" \
--notes "Raw export for LI message training set"Dry run (parse + hash only):
node scripts/ingest-heyreach-export.mjs --file /path/to/heyreach-export.json --dry-runIdempotency
The script computes a sha256 over the raw file content and inserts it as payload_sha256. The table has a unique index on payload_sha256, so re-ingesting the exact same file should fail as a duplicate.
Notes / caveats
- This stores raw JSON and may include PII. Treat exports as sensitive and restrict access to the Supabase project accordingly.
- There are no anon/auth policies for this table; it is intended for service-role access only.