Get the FREE Ultimate OpenClaw Setup Guide →

bitrix24-agent

npx machina-cli add skill vrtalex/bitrix24-skill/bitrix24-agent --openclaw
Files (1)
SKILL.md
6.6 KB

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:

  1. Pick intent + one minimal pack (core by default).
  2. Run a read probe first.
  3. 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

  1. Determine intent:
  • method call
  • troubleshooting
  • architecture decision
  • event/reliability setup
  1. 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.*).
  1. Choose auth quickly:
  • one portal/internal integration: webhook
  • app or multi-portal lifecycle: OAuth
  1. 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 codeTypical causeImmediate action
WRONG_AUTH_TYPEmethod called with wrong auth modelswitch webhook/OAuth model for this method
insufficient_scopemissing scopeadd scope and reinstall/reissue auth
expired_tokenOAuth token expiredrefresh token (--auto-refresh or external refresh flow)
QUERY_LIMIT_EXCEEDEDburst above portal budgetbackoff, queue, tune limiter, reduce concurrency
ERROR_BATCH_LENGTH_EXCEEDEDbatch payload too largesplit batch
ERROR_BATCH_METHOD_NOT_ALLOWEDunsupported method in batchcall 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

  1. references/packs.md for pack and loading strategy.
  2. references/catalog-<pack>.md for method shortlist.
  3. references/chains-<pack>.md for implementation chains.
  4. 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.

Source

git clone https://github.com/vrtalex/bitrix24-skill/blob/main/skills/bitrix24-agent/SKILL.mdView on GitHub

Overview

Design, implement, debug, and harden integrations between AI agents and the Bitrix24 REST API, covering webhooks, OAuth 2.0, scopes, events, batch operations, rate limits, and REST 3.0. Use this skill to connect AI assistants to Bitrix24, automate CRM/tasks/chats, process Bitrix24 events, choose an auth model, or troubleshoot API errors and performance issues. It emphasizes lean, reliable defaults with low token usage for production safety.

How This Skill Works

Start by clarifying intent and selecting the default core pack. Run a read probe to verify access, then proceed with writes only after planning. For writes, generate a plan first and require confirmation before execution, with safety rails like two-phase writes and idempotency. The flow relies on environment prerequisites (domain, auth mode) and a guided routing workflow to ensure reliable Bitrix24 integrations.

When to Use It

  • You need to connect an AI assistant to Bitrix24 REST API to automate CRM leads, tasks, or chats.
  • You want to process Bitrix24 events in real-time via webhooks and trigger AI-driven workflows.
  • You must decide between webhook vs OAuth authentication for a new Bitrix24 integration.
  • You are troubleshooting Bitrix24 API errors, performance issues, or rate-limit problems.
  • You aim to build production-safe integrations with minimal token usage and automated guardrails.

Quick Start

  1. Step 1: Pick intent + one minimal pack (core by default).
  2. Step 2: Run a read probe with the Bitrix24 client (user.current).
  3. Step 3: For writes, create a plan and then execute with confirmation (--confirm-write).

Best Practices

  • Start with a read probe to verify connectivity and permissions before any writes.
  • Use lean defaults: load only needed references and keep packs limited to core by default.
  • For writes, use a plan-first flow: generate a plan, review it, then execute with confirmation.
  • Enforce safety rails: require a plan, confirm-write, confirm-destructive, enable idempotency, and maintain an audit trail.
  • Configure runtime prerequisites and guardrails (B24_DOMAIN, B24_AUTH_MODE, rate limiter settings) to ensure reliability.

Example Use Cases

  • An AI agent creates a Bitrix24 lead from a user conversation, automating CRM capture.
  • A webhook-driven workflow publishes Bitrix24 event data to an AI system for downstream processing.
  • A multi-portal Bitrix24 integration using OAuth with auto-refresh keeps tokens valid across tenants.
  • A diagnostic flow analyzes a failing Bitrix24 REST 3.0 batch call and suggests fixes.
  • A lean, production-ready integration using core packs and guardrails minimizes token usage while remaining reliable.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers