Danil Sidorov
RU EN DE
Telegram

Protocol generator

A protocol for every Bitrix request is assembled automatically

Интеграция API / Документооборот

Live interactive demo stand

An exact copy of the project interface and business logic with demo data. All actions run in real time.

30 секунд на протокол вместо 45 минут ручной вёрстки

StackPython, Flask, Bitrix24 REST API, Google Sheets API, python-docx, LibreOffice

Safe perimeter (NDA): production logic on test data

What to test in the stand:
  1. Запустите вебхук из робота смарт-процесса Битрикс24
  2. Отследите автоматическую подгрузку методик и таблиц испытаний
  3. Откройте интерактивный предпросмотр протокола испытаний A4 с синей печатью
https://portal.lab-demo.ru/crm/type/1038/details/1042/
Live Stand

Протокол испытаний № 2611-07

Смарт-процесс «Протоколы испытаний» · элемент 1042

О протоколе

Для генерации

Оборудованиезаполнит сервис после генерации
Протокол (Word и PDF)
файлов нет

Turnkey implementation

Need a similar system for your business processes?

I will develop the architecture, fault-tolerant backend, and fast interface. Protected by NDA, clean transferable code, and transparent milestones.

  1. Free timeline and budget estimate within one day
  2. Contract and invoice
  3. Warranty and post-launch support

On weekdays usually within a couple of hours

I will reply personally, no aggressive sales pitch

Task

Protocols were filled in by hand for every request. It took time and the wording differed from one document to another.

Solution

I wrote an endpoint service in Python. It receives a request, pulls in data through the Google API, runs it through text processing and returns a finished protocol. It is connected to Bitrix, so documents are created within the existing process.

What was done

  • Wrote a Python (WSGI) endpoint service that generates protocols
  • Pulled in data through the Google API
  • Added text processing and assembly of the protocol in one format
  • Connected the service to Bitrix to fit the existing process

Result

The protocol for each request is assembled automatically and in one format. Filling in templates by hand is gone from the process.

Developer's note

Danil Sidorov
Danil Sidorov Project developer

What was hard

The main difficulty was preserving stable layout across multi-page tables when converting Word documents to PDF via headless LibreOffice on Linux. Test protocols contained a variable number of parameters ranging from three to dozens of rows, causing tables to frequently split across page boundaries. Without low-level XML attributes, Word would split table rows mid-text and omit column headers on subsequent pages. Furthermore, the absence of standard fonts on the host altered line spacing, pushing expert signatures and the blue seal stamp onto an unintended blank page. I resolved this by injecting specific XML properties to prevent row splitting, repeating table headers across every page, and standardizing font metrics inside an isolated container.

Another challenge involved Google Sheets API rate limits and race conditions during simultaneous document generation. Laboratory technicians occasionally updated test methods directly during generation runs, leaving empty cells or invalid data types in tolerance columns. When the Bitrix24 automation dispatched several webhooks in rapid succession, the service exceeded Google API quotas and timed out. I introduced local in-memory caching with automatic cache invalidation for reference catalogs, added strict cell normalization with sensible fallback values, and set up a resilient task queue with exponential backoff retries.

What came easy

Connecting to the Bitrix24 smart process REST API went smoothly. The webhook payload format and methods for reading custom entity fields were straightforward, allowing me to link incoming automation triggers to the Flask backend within a single afternoon. Updating pipeline stages and attaching the generated Word and PDF files back to the CRM item required only minimal boilerplate code.

Designing the templating engine for calculating and inserting test parameters was also simple. Separating the static document layout from the dynamic tabular data made it painless to assemble protocol sections based on method identifiers. When the laboratory introduced new textile density tests, the generator ingested the updated spreadsheet rows seamlessly without any code modifications.

Technologies

PythonGoogle APIBitrix

Tell me about your task

Telegram