Skip to main content
Copy every contact Darwin captures into your CRM every 15 minutes, and record Darwin’s contact id back so later runs update the same record. You need: a key with contacts:read (and contacts:write if you write the CRM’s id back), and a place to keep one timestamp between runs.
sync-contacts.mjs
Run it on a schedule (cron, a scheduled function, or your integration platform). The first run, with no lastRun, copies every contact.
  • Writing external_id changes the contact, so it comes back once in the next run. The if (!contact.external_id) check makes that second pass a no-op.
  • Each contact can have one external_id, unique in the workspace. Two contacts with the same id return 409 conflict.
  • For the conversation behind a lead, list GET /v1/conversations?has_lead=true&updated_since=… and match on contact.
  • If you’d rather not poll, subscribe a webhook to lead.captured and upsert the contact in data.object. Keep this job as a nightly safety net for any webhook you miss.
It worked if a test lead from your live chat appears in the CRM after the next run, and GET /v1/contacts?email=… shows the CRM’s id as external_id.