MMOOZZGG.com

How to build an AI agent

CRM AI assistant: build a chatbot with a model in Bitrix24 yourself

7 min read13 sources

A CRM AI assistant in Bitrix24 can be built without a separate app: an inbound webhook, a chatbot on the imbot.v2 methods and n8n with an open model are enough. Below, following the Bitrix24 documentation, we show how to build a bot that answers staff in the internal chat and how to write a lead into the CRM.

On this page · 6 sections

Build it yourself in a week

What you can build yourself

You can build an assistant for staff in Bitrix24 yourself: a bot in the internal chat answers from your policies, price list and instructions. A second use case: the agent receives the text of a request and creates a lead in the CRM.

You need three things. A REST API, the way a program calls Bitrix24 at an address with its own rights. n8n on a server with a domain and HTTPS, a program for building workflows. And a model: Ollama runs open models on your computer or server and comes under the MIT license.

We leave answers to customers in open channels, meaning messengers and website chat connected to Bitrix24, to a developer. They need handover to a person, a queue and work with personal data.

Step 1: an inbound webhook

An inbound webhook in Bitrix24 is a permanent address through which n8n calls the portal’s methods within the chosen rights. You need no separate app for this.

1. Open “Applications”, then “Developer resources”, the “Ready-made scenarios” tab, the “Other” section and the “Inbound webhook” item.

2. In the rights, tick imbot for the chatbot and crm for writing to the CRM. Rights here are called scope: the parts of the portal the webhook can access.

3. Save the webhook and copy its address, like https://portal/rest/user-id/code/. Method names are then added to this address.

If there is no “Inbound webhook” item, the right to create webhooks is closed. An administrator opens it in “Settings”, “Bitrix24 settings”, “Security”, “Bitrix24 integrations”, in the field “Who may create inbound webhooks”.

The code in the address is a secret: with it, anyone can call methods within the webhook’s rights. Do not publish the address or put it in your website code. Use POST for working calls: GET requests end up in browser history, logs and monitoring systems.

Step 2: a chatbot in Bitrix24

Chatbots 2.0 in Bitrix24 are registered with the imbot.v2.Bot.register method. The bot sends its reply to an employee with the imbot.v2.Chat.Message.send method, and both methods are called through the inbound webhook address.

1. In n8n, create a workflow with a “Webhook” node, choose POST in the “HTTP Method” field, publish the workflow and copy the “Production URL”. Bitrix24 will send messages for the bot to this address.

2. Call imbot.v2.Bot.register with an “HTTP Request” node or with the curl command from the documentation’s quick start. In the fields object, pass code (the bot’s code), botToken (a secret of up to 40 characters that you make up), type set to bot, eventMode set to webhook, webhookUrl with the address from n8n and properties with the bot’s name.

3. Save the bot id from the reply: together with botToken, you need it in every later call. A repeat call with the same code returns the same bot instead of creating a second one.

If you do not have a public address yet, register the bot with eventMode fetch. Then events pile up in Bitrix24, and the program collects them itself with the imbot.v2.Event.get method, with no handler and no public address. This is enough to test the idea.

Step 3: the model and the reply in the chat

1. Write to the bot in Bitrix24. n8n receives the ONIMBOTV2MESSAGEADD event: it holds the dialog address dialogId and the message text.

2. After the “Webhook” node, place “AI Agent”. In the “Prompt” parameter choose “Define below” and insert the message text into the “Prompt (User Message)” field.

3. In the node options, add a “System Message” and write the rules: which questions the bot answers, which documents it relies on and to whom it sends everything else.

4. Connect a model, for example the “Ollama Chat Model” node with an open model on your own server. The n8n documentation also requires at least one tool connected to the agent, for example a search across the policy base.

5. Send the reply with an “HTTP Request” node: a POST to the webhook address with the imbot.v2.Chat.Message.send method. In the JSON body, pass botId, botToken, dialogId from the event and fields with a message field that holds the model’s answer.

In a private chat the bot receives every message, but in a group chat events do not arrive for all messages. To begin with, test the bot in a private dialog.

Step 4: writing to the CRM

The crm.item.add method creates leads and deals. In the entityTypeId parameter, pass 1 for a lead or 2 for a deal, and in fields the title and the customer data the model pulled from the request text.

The documentation marks the crm.lead.add method as outdated: its development has stopped, so use crm.item.add for new workflows.

The method runs on behalf of the user who created the webhook and requires that user to have the right to add records to the CRM. So create the agent’s webhook from a separate user with access only to the needed pipeline: a model error will not touch other people’s deals.

Customer names and phone numbers go into the CRM, and these are personal data. Under 152-FZ, Russia’s personal data law, they are collected and stored in databases in Russia, and since 1 March 2023 the operator notifies Roskomnadzor, the Russian regulator, before transferring them abroad. Keep the model that reads requests on your own server in Russia; more on the data security page.

When you need a developer

The bot in this guide answers single questions. An agent that guides a customer in open channels, remembers the history, moves a deal through the pipeline and hands the conversation to a manager in time needs development and testing on real dialogs.

We connect such an agent as a turnkey project: a pilot in 14 days from $1,499 with a metric in the contract. The AI agent for Bitrix24 page describes what the agent does inside the portal, and we covered how to choose a CRM for an agent on the blog.

n8n in this build comes under the Sustainable Use License (fair-code): you may install and change it for yourself, but not resell it as a cloud service. A similar build for amoCRM has its own guide.

Questions and answers

Do you need a public server for a Bitrix24 bot?

Not to test the idea: in fetch mode the bot collects events itself with the imbot.v2.Event.get method, and no public address is needed. In webhook mode, Bitrix24 sends events to the handler’s address, so n8n must be reachable at a public address.

Can such a bot answer customers in open channels?

Technically yes: at registration the bot gets the isSupportOpenline parameter. But in open channels the bot talks to customers on behalf of the company, processes their personal data and must hand the conversation to a person in time. Build this use case with a developer and test it in a pilot.

Sources and fact-checking

Checked by the editors on 16 October 2026.

  1. Bitrix24 REST API: local webhooks, 2026 (apidocs.bitrix24.ru)
  2. Bitrix24 REST API: imbot.v2.Bot.register, 2026 (apidocs.bitrix24.ru)
  3. Bitrix24 REST API: chatbots 2.0, quick start, 2026 (apidocs.bitrix24.ru)
  4. Bitrix24 REST API: crm.item.add, 2026 (apidocs.bitrix24.ru)
  5. Bitrix24 REST API: crm.lead.add, 2026 (apidocs.bitrix24.ru)
  6. Alpine Linux packages, 2026 (pkgs.alpinelinux.org)
  7. Brace Law Firm, 9 July 2023 (brace-lf.com)
  8. Wikipedia, 2026 (en.wikipedia.org)
  9. Bitrix24 documentation: imbot.v2 event formats, checked 16 October 2026 (apidocs.bitrix24.ru)
  10. n8n documentation: Webhook node, checked 16 October 2026 (docs.n8n.io)
  11. n8n documentation: AI Agent node, checked 16 October 2026 (docs.n8n.io)
  12. n8n documentation: Tools Agent, checked 16 October 2026 (docs.n8n.io)
  13. n8n documentation: HTTP Request node, checked 16 October 2026 (docs.n8n.io)

Found a mistake? Tell us

Publications

Contact us