How to create a bot in MAX: business requirements, security and architecture

19.02.20264 min read
Vadim Yurievich
General DirectorVadim Yurievich

Companies are increasingly abandoning simple scripted chatbots in favor of intelligent agents based on MAX. But developing a smart bot is fundamentally different from creating a business card in the designer. If the right foundation of access, roles and security policies is not laid at the start, the project will quickly turn into uncontrollable chaos.

Let's look at the technical and business background of launching a MAX bot: what requirements need to be recorded before writing the first line of code.


1. Business requirements: functionality dictates architecture

Before requesting API tokens, you need to answer the question: “Where is the boundary of a bot’s autonomy?”

Developers are not satisfied with technical specifications like this “he must answer questions”. We need a strict behavior framework:

  • Target Scenario (Happy Path): For example, lead generation (collect name, phone number, need → record in CRM) or first line support (determine order status in ERP → respond to client).
  • Escalation Matrix: What are the triggers for the bot? obliged transfer the dialogue to a live operator? (Example: the words “complaint”, “court”, or the bot did not understand the request 2 times in a row).
  • Role model: Who has the right to change the bot's logic? Who sees the dialogue logs? Who can launch mailings?

Important: Without fixed KPIs (a 15% increase in conversion or a 30% reduction in call center workload), bot development will turn into an endless process of testing hypotheses.


2. Tokens, accesses and Webhook infrastructure

MAX-bot is not a standalone application. This is a server (handler) that responds to external platform events. To configure this bridge you need:

  1. Authorization token (API Key): The key that the platform gives to your bot. Iron Rule of Implementation: Tokens never stored in code (Hardcode). They must be in environment variables (.env) or in secret vaults at the HashiCorp Vault level.
  2. Server access: The bot works via Webhooks. Your server needs a static IP address and a valid SSL certificate (platforms do not send HTTP hooks).
  3. Access to external systems: If the bot needs to generate leads in Bitrix24 or amoCRM, you will need OAuth tokens of these systems or incoming webhooks for the REST API.

3. Basic security model (Security First)

Bots often become a channel for leaking personal data. Basic security checklist for MAX bot:

  • Validation of incoming traffic: The bot server must check that the POST request came from the MAX servers (usually the header signature is checked using secret_key), and not from a random IP.
  • Input sanitization: An SQL injection or XSS payload may be sent to the dialogue instead of a name. All incoming text data must be escaped before being written to the database or CRM.
  • Scope limitation: The CRM token issued to the bot must have rights only to create a lead, but not to delete deals or change portal settings.
  • Consent to processing (152-FZ): At the first touch, the bot must obtain the user’s explicit consent to process personal data, otherwise the company will receive a fine.

4. Architecture of integration with CRM / ERP

The problem with 80% of bots is lost leads due to failures. Integration should be built on the principle of fault tolerance:

  • What to do when there is a timeout? If the Bitrix24 API hangs and times out, the bot should not write to the client “A system error has occurred.” He should respond “Great, I passed the information to the subject specialist,” and put the data in a local queue (Redis/RabbitMQ) for resending.
  • Deduplication: How does a bot understand that a client has a Telegram-ID? 12345 and a client with a number +7999... - is this the same person? Setting up rules for merging duplicates - the job of a business analyst before the start of the project.
  • Tracking end-to-end analytics: The bot must be able to capture and forward UTM tags (if the user switched to the bot from a landing page) directly into the deal card.

Need a fault-tolerant smart bot?

Discuss architecture, limits and scenarios with NBM-IT technical specialists.


5. DevOps checklist before launching into production

Even perfect code can fail under load. Before announcing the bot, check:

  1. Fallback script configured.(Answer is a stub when the backend crashes).
  2. Logging and Monitoring. Sentry or ELK Stack integrated. The developer should receive an alert in Telegram if errors occur in the bot 500 Internal Server Error.
  3. Rate Limiting has been configured. So that competitors cannot spam the bot with thousands of messages per second by relying on your server.
  4. Separate sandbox. Development and testing should be carried out in a separate test bot (Test Environment) so as not to affect production clients.

Bottom line

Launching a smart bot in MAX is a full-fledged IT integration project. If you want the bot to actually sell and support customers, and not just irritate them with template answers, you need to approach its design systematically.

The NBM-IT web development team designs fault-tolerant architecture for complex bots. We connect messengers, AI engines and your corporate CRM into a single secure ecosystem. Contact us to audit your automation process.

Leave your contacts - we will call you back, sort out the problem and offer the best way. We have more than 350 projects behind us, each of which we launched with an individual approach. We guarantee expert advice during business hours.