v1.2.0

Task automation on stage transitions

Poll deal stages every 60 s. When a watched transition fires, create a task with description, deadline and priority.

What it does

Loads open deals (excluding WON/LOSE) every minute, compares each stage with the previously seen value, and on each watched transition (EXECUTING, PREPAYMENT_INVOICE, FINAL_INVOICE by default) creates a task bound to the deal via UF_CRM_TASK.

Stack

Node.js 18+. No external dependencies.

Environment

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

Run

npx tsx 03-task-automation.ts

Source

skills/b24jssdk-recipes/examples/03-task-automation.ts.

Notes

  • State (dealStages) is held in memory. Restart loses it by design — for production persist to disk or Redis.
  • Polling is wasteful at scale; the Pull-driven variant (subscribe to 'crm' events) is on the suggestion list.
  • Multi-funnel portals: the recipe uses a baseStage() helper to match C<n>:EXECUTING, etc.