v1.2.0

ERP / 1C contact sync

Two-way contact sync between Bitrix24 and an external ERP. Match by INN (primary) or email (fallback). Cron every hour.

What it does

Pulls contacts from both Bitrix24 (via actions.v2.fetchList.make) and an external ERP (mocked in the recipe — replace with your client). Matches them by tax id (ufCrmInn) primarily and email as a fallback. Creates missing rows on each side and syncs changed name fields back to Bitrix24.

Stack

Node.js 18+, node-cron.

Install

pnpm add node-cron

Environment

export B24_HOOK='https://your.bitrix24.com/rest/1/secret'

Run

npx tsx 04-erp-sync.ts

Source

skills/b24jssdk-recipes/examples/04-erp-sync.ts.

Notes

  • ERP-side functions (fetchErpContacts, createErpContact, updateErpContact) are stubs. Plug in your client (1C OData, REST, etc.).
  • The matching key is ufCrmInn — adjust the field name to whatever your custom-field namespace uses.
  • For thousands of contacts the per-row createBitrixContact await loop is the bottleneck. Replace it with actions.v2.batchByChunk.make({ calls: erpContacts.map((e) => ['crm.item.add', { entityTypeId: 3, fields: ... }]), options: { isHaltOnError: false } }) — see recipe 5 (Disk files) for the basic batch.make shape and the b24jssdk-rest skill for batchByChunk.make details.