Sync Notion to Hindsight with Cloudflare Workflows
Background
We all love Hindsight, but it could be a trouble thing if you want manage your knowledge base with Hindsight, you’ll have to add all the knowledge manually, and there isn’t a way to import the knowledge from external sources like Notion, and that’s why I made this project.
github.comHow it works
notion-to-hindsight-sync keeps pages from a Notion data source in a Hindsight memory bank. It runs hourly cron (Could be changed) on Cloudflare Worker, syncs only new or changed pages, and removes documents whose source pages have disappeared. You can configure multiple source-to-bank mappings.
Data flow
flowchart LR
C[Cloudflare Cron] --> T[For each target]
T --> N[Read Notion<br/>pages]
T --> H[Read Hindsight<br/>documents]
N --> X{Compare page<br/>IDs and revisions}
H --> X
X -->|Unchanged| S[Skip]
X -->|New or changed| PIPE
subgraph PIPE["Changed-page sync"]
direction TB
F[Fetch Markdown<br/>and properties]
R[Retain in<br/>Hindsight]
W[Wait for success]
I[Recheck both<br/>inventories]
D[Delete missing<br/> Hindsight documents]
F --> R --> W --> I --> D
endThe Notion page ID is the stable document ID. The page's last_edited_time identifies changes. The retained content contains both the page Markdown and its original property JSON, including dates, relations and select values. Each target runs in its own Workflow; deletion is limited to documents tagged for that particular source.
Set it up
1. Gather your IDs and credentials
Create a Notion integration or Personal Access Token, grant it access to the pages you want to sync, and copy its token and the data source ID (You can find it with Developer Mode in Notion). Have your Hindsight base URL and destination bank ID ready. If your Hindsight endpoint requires bearer authentication or Cloudflare Access, get those credentials too.
2. Create the Worker
Clone the worker with this link:
deploy.workers.cloudflare.comEdit the environments. Set NOTION_TOKEN, HINDSIGHT_BASE_URL, and SYNC_TARGETS. SYNC_TARGETS is a JSON array. Start with one mapping (replace both placeholder IDs):
[
{
"key": "personal",
"notionDataSourceId": "YOUR_NOTION_DATA_SOURCE_ID",
"hindsightBankId": "YOUR_HINDSIGHT_BANK_ID",
"retainStrategy": "Default" // Optional
}
]Add more objects for more mappings; each key must be unique and contain only letters, numbers, underscores, or hyphens. You can give a target a retainStrategy to override its bank's default.
Optional secrets are HINDSIGHT_API_KEY, CF_ACCESS_CLIENT_ID, and CF_ACCESS_CLIENT_SECRET. Do not commit credentials.
3. Trigger and inspect your first sync
Use the key from your configuration in the manual trigger, then inspect the instance:
npx wrangler workflows trigger notion-hindsight-sync '{"targetKey":"personal"}'
npx wrangler workflows instances list notion-hindsight-sync
npx wrangler workflows instances describe notion-hindsight-sync <instance-id>The completion log reports created, updated, unchanged, skipped-empty, and deleted counts. To re-import unchanged pages, pass force_replace: true in the trigger payload. If migrating an older deployment, move the previous NOTION_DATA_SOURCE_ID and HINDSIGHT_BANK_ID values into one SYNC_TARGETS item; those old secrets are no longer read. For full configuration details, see the README.