Bitrix24 Agent (Lean + Reliable)
Use this skill to deliver correct Bitrix24 integrations with low token usage and production-safe defaults.
Quick Start
Use this flow unless the user asks for a different one:
- Pick intent + one minimal pack (
core by default).
- Run a read probe first.
- For writes, use plan then execute with confirmation.
Read probe:
python3 skills/bitrix24-agent/scripts/bitrix24_client.py user.current --params '{}'
Safer write flow:
python3 skills/bitrix24-agent/scripts/bitrix24_client.py crm.lead.add \
--params '{"fields":{"TITLE":"Plan demo"}}' \
--packs core \
--plan-only
python3 skills/bitrix24-agent/scripts/bitrix24_client.py \
--execute-plan <plan_id> \
--confirm-write
Runtime Prerequisites
Required environment:
B24_DOMAIN
B24_AUTH_MODE = webhook or oauth
Webhook mode:
B24_WEBHOOK_USER_ID
B24_WEBHOOK_CODE
OAuth mode:
B24_ACCESS_TOKEN
B24_REFRESH_TOKEN
B24_CLIENT_ID and B24_CLIENT_SECRET (for --auto-refresh)
Useful safety/reliability flags:
B24_REQUIRE_PLAN=1 for mandatory plan->execute on write/destructive calls
B24_PACKS=core,... for default pack set
B24_RATE_LIMITER=file with B24_RATE_LIMITER_RATE and B24_RATE_LIMITER_BURST
Default Mode: Lean
Apply these limits unless the user asks for deep detail:
- Load at most 2 reference files before first actionable step.
- Start from
references/packs.md.
- Then open only one target file:
references/catalog-<pack>.md.
- Open
references/chains-<pack>.md only if the user needs workflow steps.
- Open
references/bitrix24.md only for auth architecture, limits, event reliability, or unknown errors.
Response limits:
- Use concise output (goal + next action + one command).
- Do not retell documentation.
- Do not dump large JSON unless requested.
- Return only delta if guidance was already given.
Routing Workflow
- Determine intent:
- method call
- troubleshooting
- architecture decision
- event/reliability setup
- Normalize product vocabulary:
- "collabs", "workgroups", "projects", "social network groups" ->
collab (and boards for scrum).
- "Copilot", "CoPilot", "BitrixGPT", "AI prompts" ->
platform (ai.*).
- "open lines", "contact center connectors", "line connectors" ->
comms (imopenlines.*, imconnector.*).
- "feed", "live feed", "news feed" ->
collab (log.*).
- "sites", "landing pages", "landing" ->
sites (landing.*).
- "booking", "calendar", "work time", "time tracking" ->
services (booking.*, calendar.*, timeman.*).
- "orders", "payments", "catalog", "products" ->
commerce (sale.*, catalog.*).
- "consents", "consent", "e-signature", "sign" ->
compliance (userconsent.*, sign.*).
- Choose auth quickly:
- one portal/internal integration: webhook
- app or multi-portal lifecycle: OAuth
- Select minimal packs:
- default
core
- add only required packs:
comms, automation, collab, content, boards, commerce, services, platform, sites, compliance, diagnostics
Execution Flow (Safe by Default)
Command template:
python3 skills/bitrix24-agent/scripts/bitrix24_client.py <method> \
--params '<json>' \
--packs core
Guardrails to enforce:
- allowlist via packs and
--method-allowlist
- write gate with
--confirm-write
- destructive gate with
--confirm-destructive
- optional two-phase write with
--plan-only and --execute-plan
- idempotency for writes (auto or
--idempotency-key)
- audit trail unless
--no-audit is explicitly needed
Reliability and Performance
Pagination and sync safety:
- Never stop after first
*.list page.
- Keep deterministic ordering and persist checkpoints after successful page persistence.
Batch rules:
- Maximum 50 commands per
batch.
- No nested
batch.
- Split oversized batches and parse per-command errors.
Limits and retries:
- Treat
QUERY_LIMIT_EXCEEDED and 5xx as transient.
- Use exponential backoff with jitter (client default).
- Use shared rate limiter keyed by portal in multi-worker setups.
Events:
- Online events are not guaranteed delivery.
- For no-loss pipelines, use offline flow:
event.offline.get(clear=0)
- process idempotently with retry budget
event.offline.error for failed items
event.offline.clear only for successful/DLQ'ed items
- Use
scripts/offline_sync_worker.py as baseline.
Error Handling
Fast mapping:
| Error code |
Typical cause |
Immediate action |
WRONG_AUTH_TYPE |
method called with wrong auth model |
switch webhook/OAuth model for this method |
insufficient_scope |
missing scope |
add scope and reinstall/reissue auth |
expired_token |
OAuth token expired |
refresh token (--auto-refresh or external refresh flow) |
QUERY_LIMIT_EXCEEDED |
burst above portal budget |
backoff, queue, tune limiter, reduce concurrency |
ERROR_BATCH_LENGTH_EXCEEDED |
batch payload too large |
split batch |
ERROR_BATCH_METHOD_NOT_ALLOWED |
unsupported method in batch |
call directly |
Escalate to deep reference (references/bitrix24.md) on:
- unknown auth/permission behavior
- recurring limit failures
- offline event loss concerns
- OAuth refresh race or tenant isolation issues
Quality Guardrails
- Never expose webhook/OAuth secrets.
- Enforce least-privilege scopes and tenant isolation.
- Keep writes idempotent where possible.
- Validate
application_token in event handlers.
- Prefer REST v3 where compatible; fallback to v2 where needed.
Reference Loading Map
references/packs.md for pack and loading strategy.
references/catalog-<pack>.md for method shortlist.
references/chains-<pack>.md for implementation chains.
references/bitrix24.md for protocol-level troubleshooting and architecture decisions.
Useful search shortcuts:
rg -n "^# Catalog|^# Chains" references/catalog-*.md references/chains-*.md
rg -n "WRONG_AUTH_TYPE|insufficient_scope|QUERY_LIMIT_EXCEEDED|expired_token" references/bitrix24.md
rg -n "offline|event\\.bind|event\\.offline|application_token" references/bitrix24.md
Scripts
scripts/bitrix24_client.py: method calls, packs, allowlist, confirmations, plans, idempotency, audit, rate limiting, retries.
scripts/offline_sync_worker.py: offline queue polling, bounded retries, DLQ handling, safe clear flow, graceful shutdown.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: bitrix24-agent3description: Design, implement, debug, and harden integrations between AI agents and Bitrix24 REST API (webhooks, OAuth 2.0, scopes, events, batch, limits, and REST 3.0). Use when asked to connect AI assistants/agents to Bitrix24, automate CRM/tasks/chats, process Bitrix24 events, choose an auth model, or resolve Bitrix24 API errors and performance issues. Use when this capability is needed.4---56# Bitrix24 Agent (Lean + Reliable)78Use this skill to deliver correct Bitrix24 integrations with low token usage and production-safe defaults.910## Quick Start1112Use this flow unless the user asks for a different one:13141. Pick intent + one minimal pack (`core` by default).152. Run a read probe first.163. For writes, use plan then execute with confirmation.1718Read probe:1920```bash21python3 skills/bitrix24-agent/scripts/bitrix24_client.py user.current --params '{}'22```2324Safer write flow:2526```bash27python3 skills/bitrix24-agent/scripts/bitrix24_client.py crm.lead.add \28 --params '{"fields":{"TITLE":"Plan demo"}}' \29 --packs core \30 --plan-only3132python3 skills/bitrix24-agent/scripts/bitrix24_client.py \33 --execute-plan <plan_id> \34 --confirm-write35```3637## Runtime Prerequisites3839Required environment:4041- `B24_DOMAIN`42- `B24_AUTH_MODE` = `webhook` or `oauth`4344Webhook mode:4546- `B24_WEBHOOK_USER_ID`47- `B24_WEBHOOK_CODE`4849OAuth mode:5051- `B24_ACCESS_TOKEN`52- `B24_REFRESH_TOKEN`53- `B24_CLIENT_ID` and `B24_CLIENT_SECRET` (for `--auto-refresh`)5455Useful safety/reliability flags:5657- `B24_REQUIRE_PLAN=1` for mandatory plan->execute on write/destructive calls58- `B24_PACKS=core,...` for default pack set59- `B24_RATE_LIMITER=file` with `B24_RATE_LIMITER_RATE` and `B24_RATE_LIMITER_BURST`6061## Default Mode: Lean6263Apply these limits unless the user asks for deep detail:6465- Load at most 2 reference files before first actionable step.66- Start from `references/packs.md`.67- Then open only one target file: `references/catalog-<pack>.md`.68- Open `references/chains-<pack>.md` only if the user needs workflow steps.69- Open `references/bitrix24.md` only for auth architecture, limits, event reliability, or unknown errors.7071Response limits:7273- Use concise output (goal + next action + one command).74- Do not retell documentation.75- Do not dump large JSON unless requested.76- Return only delta if guidance was already given.7778## Routing Workflow79801. Determine intent:81- method call82- troubleshooting83- architecture decision84- event/reliability setup85862. Normalize product vocabulary:8788- "collabs", "workgroups", "projects", "social network groups" -> `collab` (and `boards` for scrum).89- "Copilot", "CoPilot", "BitrixGPT", "AI prompts" -> `platform` (`ai.*`).90- "open lines", "contact center connectors", "line connectors" -> `comms` (`imopenlines.*`, `imconnector.*`).91- "feed", "live feed", "news feed" -> `collab` (`log.*`).92- "sites", "landing pages", "landing" -> `sites` (`landing.*`).93- "booking", "calendar", "work time", "time tracking" -> `services` (`booking.*`, `calendar.*`, `timeman.*`).94- "orders", "payments", "catalog", "products" -> `commerce` (`sale.*`, `catalog.*`).95- "consents", "consent", "e-signature", "sign" -> `compliance` (`userconsent.*`, `sign.*`).96973. Choose auth quickly:9899- one portal/internal integration: webhook100- app or multi-portal lifecycle: OAuth1011024. Select minimal packs:103104- default `core`105- add only required packs: `comms`, `automation`, `collab`, `content`, `boards`, `commerce`, `services`, `platform`, `sites`, `compliance`, `diagnostics`106107## Execution Flow (Safe by Default)108109Command template:110111```bash112python3 skills/bitrix24-agent/scripts/bitrix24_client.py <method> \113 --params '<json>' \114 --packs core115```116117Guardrails to enforce:118119- allowlist via packs and `--method-allowlist`120- write gate with `--confirm-write`121- destructive gate with `--confirm-destructive`122- optional two-phase write with `--plan-only` and `--execute-plan`123- idempotency for writes (auto or `--idempotency-key`)124- audit trail unless `--no-audit` is explicitly needed125126## Reliability and Performance127128Pagination and sync safety:129130- Never stop after first `*.list` page.131- Keep deterministic ordering and persist checkpoints after successful page persistence.132133Batch rules:134135- Maximum 50 commands per `batch`.136- No nested `batch`.137- Split oversized batches and parse per-command errors.138139Limits and retries:140141- Treat `QUERY_LIMIT_EXCEEDED` and `5xx` as transient.142- Use exponential backoff with jitter (client default).143- Use shared rate limiter keyed by portal in multi-worker setups.144145Events:146147- Online events are not guaranteed delivery.148- For no-loss pipelines, use offline flow:149 - `event.offline.get(clear=0)`150 - process idempotently with retry budget151 - `event.offline.error` for failed items152 - `event.offline.clear` only for successful/DLQ'ed items153- Use `scripts/offline_sync_worker.py` as baseline.154155## Error Handling156157Fast mapping:158159| Error code | Typical cause | Immediate action |160|---|---|---|161| `WRONG_AUTH_TYPE` | method called with wrong auth model | switch webhook/OAuth model for this method |162| `insufficient_scope` | missing scope | add scope and reinstall/reissue auth |163| `expired_token` | OAuth token expired | refresh token (`--auto-refresh` or external refresh flow) |164| `QUERY_LIMIT_EXCEEDED` | burst above portal budget | backoff, queue, tune limiter, reduce concurrency |165| `ERROR_BATCH_LENGTH_EXCEEDED` | batch payload too large | split batch |166| `ERROR_BATCH_METHOD_NOT_ALLOWED` | unsupported method in batch | call directly |167168Escalate to deep reference (`references/bitrix24.md`) on:169170- unknown auth/permission behavior171- recurring limit failures172- offline event loss concerns173- OAuth refresh race or tenant isolation issues174175## Quality Guardrails176177- Never expose webhook/OAuth secrets.178- Enforce least-privilege scopes and tenant isolation.179- Keep writes idempotent where possible.180- Validate `application_token` in event handlers.181- Prefer REST v3 where compatible; fallback to v2 where needed.182183## Reference Loading Map1841851. `references/packs.md` for pack and loading strategy.1862. `references/catalog-<pack>.md` for method shortlist.1873. `references/chains-<pack>.md` for implementation chains.1884. `references/bitrix24.md` for protocol-level troubleshooting and architecture decisions.189190Useful search shortcuts:191192```bash193rg -n "^# Catalog|^# Chains" references/catalog-*.md references/chains-*.md194rg -n "WRONG_AUTH_TYPE|insufficient_scope|QUERY_LIMIT_EXCEEDED|expired_token" references/bitrix24.md195rg -n "offline|event\\.bind|event\\.offline|application_token" references/bitrix24.md196```197198## Scripts199200- `scripts/bitrix24_client.py`: method calls, packs, allowlist, confirmations, plans, idempotency, audit, rate limiting, retries.201- `scripts/offline_sync_worker.py`: offline queue polling, bounded retries, DLQ handling, safe clear flow, graceful shutdown.202203---204> Converted and distributed by [TomeVault](https://tomevault.io/claim/vrtalex) — claim your Tome and manage your conversions.205<!-- tomevault:4.0:skill_md:2026-04-11 -->