Development of AI Bot for Bitrix24
Bitrix24 has a built-in Copilot — an AI assistant from Bitrix. But Copilot is a closed tool with fixed scenarios. If you need a bot to answer customer questions from your company's knowledge base, automatically create tasks from messages, score leads, or respond on behalf of managers in open channels — you need custom development.
AI Bot Architecture
An AI bot in Bitrix24 is an application registered through REST API. It receives incoming messages via webhooks, processes them (using an LLM or its own logic), and responds through API.
Diagram:
User → Bitrix24 Chat → Webhook → Bot Server → LLM API (OpenAI, Yandex GPT...) → Response → Bitrix24 API → Chat
Bot Registration is done via imbot.register method:
imbot.register
NAME = "Sales Assistant"
CODE = "sales_bot"
TYPE = "H" (Human-like) or "B" (Bot)
EVENT_MESSAGE_ADD = https://your-server.com/bot/message
EVENT_WELCOME_MESSAGE = https://your-server.com/bot/welcome
EVENT_BOT_DELETE = https://your-server.com/bot/delete
The bot appears in the user list and in open channels.
Where the Bot Works
The bot can function in several contexts:
| Context | API | Application |
|---|---|---|
| Bitrix24 Chats | im.message.add, imbot.message.add |
Internal assistant for employees |
| Open Channels | imopenlines.* |
Answers to customers in website chat, VK, Telegram |
| CRM (smart processes, robots) | bizproc.*, crm.activity.* |
Pipeline automation |
| Voice Input | Via Copilot API | Call transcription |
Open channels are the most popular context: the bot answers customers and transfers conversation to a live manager by set triggers.
Integration with LLM
Most AI bots are built on OpenAI GPT-4 or GPT-4o, Yandex GPT, or local models (LLaMA via Ollama). Interaction scheme:
- Bot receives message from user via webhook.
- Forms a prompt: system instructions (role, constraints, response style) + dialogue history (context window) + current question.
- Sends request to LLM API.
- Gets response, formats if needed.
- Sends response to Bitrix24 chat via
imbot.message.add.
Context Management. LLM doesn't store history between requests — that's the bot server's job. Dialogue history is stored in a database (Redis, PostgreSQL) with the chat_id key from Bitrix24. Each message retrieves history, adds new message, truncates to maximum context window.
RAG: Answering from Company Knowledge Base
To make the bot answer questions from company documents, products, regulations — use RAG (Retrieval-Augmented Generation):
- Indexing: knowledge base documents are split into fragments, each gets a vector representation (embedding). Stored in a vector DB (Pinecone, Qdrant, pgvector).
- Search: on user question, its embedding is created, nearest fragments are found in vector DB.
- Generation: found fragments are added to prompt as context. LLM answers based on real company data.
This eliminates LLM "hallucinations" — the bot doesn't invent answers but references uploaded materials.
Handing Off to Manager
When the bot can't answer or the customer explicitly wants a live operator — the call transfers to a manager. In open channels this is done via imopenlines.session.transfer. The bot sends "Connecting you with a manager" and calls the transfer method.
Transfer conditions:
- Keywords in message ("call me", "manager", "urgent").
- Iteration count: if bot doesn't resolve the issue in 3 messages — escalate.
- Wait time: if no response in 5 minutes — create a manager task.
Bot Actions in CRM
Besides chat responses, the bot can perform CRM actions:
- Create lead:
crm.lead.addwith data from dialogue. - Fill deal fields based on conversation analysis.
- Create task:
tasks.task.add— "Call customer at 3 PM". - Send proposal: generate PDF via
crm.quote.*and send viacrm.activity.add.
For this, the bot server calls Bitrix24 REST API on behalf of a user (OAuth 2.0 or webhook).
Development Timeline
| Option | Scope | Timeline |
|---|---|---|
| Basic | FAQ answers, handoff to manager | 5–7 days |
| With embedded knowledge base (RAG) | Document indexing, knowledge base search | 8–12 days |
| Full-featured | RAG + CRM actions + dialogue analytics | 14–20 days |







