Skip to content
← All articles
11 min read

Telegram bot 1C integration: access control, idempotency and what to do when 1C is down

A Telegram bot for 1C is a thin interface. It takes a question ("stock for this SKU", "where is order 1042"), checks who is asking, and fetches the answer from 1C through an HTTP service or OData. Three things keep it reliable: role-based access, idempotent order writes and a plan for when 1C does not respond. Below, in order, is which setup fits which case.

What does a bot do with 1C, and what is it not?

A bot does not replace 1C and does not keep the books. It is one more screen onto the same database, useful where people already live in a messenger: in the warehouse, on the road, at a customer's site. All the rules stay in 1C. The bot asks questions and passes commands.

Typical scenarios split into reads and writes. Reads: stock by item and warehouse, status of a customer order, unpaid invoices, a price, the date of the next delivery. Writes: create an order or a request, confirm a shipment, change a status. A third kind runs the other way, as notifications: 1C reports that an order is packed, and the bot tells the customer or the manager.

We covered the general landscape of exchange options in ways to integrate with 1C. This article narrows it to one scenario: a chat-based interface.

How does the bot get data from 1C: HTTP service or OData?

The 1C:Enterprise platform offers two built-in ways in from outside. The first is HTTP services: the configuration developer defines URL templates, methods and handlers. The second is the standard OData interface: a ready REST interface over the metadata objects, switched on when you publish the database on a web server. According to the 1C ITS documentation, OData is available from platform 8.3.5, and HTTP services cannot be used in compatibility mode 8.3.4 or lower. Check your platform version and compatibility mode before choosing.

The choice is usually straightforward:

  • HTTP service: when the answer should be ready and compact, such as stock for a SKU in a warehouse in one call, shaped the way the bot needs it. Business logic and calculations stay in 1C, and one narrow method is visible outside. The downside is that you need a 1C developer, and the method has to be maintained when the configuration is updated.
  • OData: when you need to read catalogues and documents as they are and you are happy to assemble the answer in the bot's code. It is quick to start, but your code does the extra work (filters, joins, formatting). You can limit which objects are published, and you should: expose only the catalogues and documents you need.
  • Both run over HTTPS under a dedicated 1C user with minimal rights. The bot must not use an administrator account, and certainly not a real employee's account.

Intermediate database or queue: when a direct call is not enough

The simplest setup: the bot calls 1C synchronously on every question and shows the answer. It works for rare requests and a small team. Its weak point: every reply depends on 1C speed, and ten people pressing a button together produce ten heavy queries.

The second setup adds an intermediate database. A separate service (for us usually Go with Postgres) periodically pulls the slices it needs from 1C, such as stock, prices and order statuses, and stores them in its own table together with an update time. The bot reads only that table. Answers are instant, the load on 1C is predictable, and the bot keeps answering even when 1C is down. The cost is slightly stale data, so the bot has to show how fresh it is.

The third setup is a queue for writes. An order created in the bot does not go straight to 1C. It is saved on your side with a unique key and queued for delivery. A worker sends it to 1C and retries with a pause on error. The user gets an honest status, "accepted, sending to 1C", instead of a frozen screen. How queues and workers are built in Go is covered in background jobs and queues in Go.

  • Rare requests, few users, freshness is critical: a direct call to an HTTP service.
  • Frequent reads of stock and prices, a lag of minutes is fine: an intermediate database refreshed on a schedule.
  • Writing orders and statuses: a queue with retries and an idempotency key.
  • Notifications from 1C to the bot: 1C or the exchange handler sends an event to your service, which then writes to Telegram.

Access control: who sees what in the bot

A bot exposes 1C data to people who used to work in an interface with roles and rights. You must not give them more than they had. Telegram knows only an account ID and has no idea who that person is in your company, so the mapping is your job.

A working scheme: the user starts the bot and enters a one-time code or follows an invitation link issued by an administrator. The service stores a link of the form Telegram ID, 1C employee or counterparty, role. From then on every action is checked against that role on your side, never trusted from the text the client sent. Any button can be triggered by hand with forged data, so the check belongs on the server.

  • Define roles by task: a manager sees their own orders, a storekeeper sees stock and shipments, a director sees summaries. The role is stored on your side, not in the button text.
  • For customers, filter strictly by counterparty: a customer sees only their own orders. A bug in that filter leaks someone else's data.
  • Dismissal and role changes must cut access at once: reconcile the links with the 1C employee catalogue or give an administrator a revoke command.
  • Keep anything sensitive out of callback_data. Telegram documents it as 1 to 64 bytes, so it carries a short identifier, not data.
  • For dangerous actions (cancel, change a price) add a separate confirmation step. How to keep such steps in a coherent dialogue is described in bot conversation state.

Idempotency: how not to create two orders

Telegram can deliver the same update again. A user can tap "Place order" twice. The network between your service and 1C can drop after 1C has already saved the document. If every such event creates an order, 1C ends up with duplicates that someone then has to find by hand.

The principle is simple: every write command carries a unique key, and a repeat with the same key returns the same result instead of performing a new action. You can build the key from the update or button identifier and the draft order identifier. The service writes the key to Postgres in the same transaction as the order and, on a repeat, returns the result that already exists. For the details of keys and retries, see API idempotency and retries.

The second half of the protection lives on the 1C side. If you create a document through an HTTP service, pass your external identifier in the request and have the handler look for a document with that identifier first. Then even if your service sent the request twice, the database keeps one document. The configuration developer has to build that into the method.

Until 1C has confirmed the write, tell the user the order is accepted, not created.

What to do when 1C is unavailable

1C will be unavailable at some point: a configuration update, a locked database, a server restart, a broken link, a heavy month-end close. A good bot neither pretends nothing happened nor loses orders. Decide in advance what a person sees in each situation.

  • Reads while 1C is down: show the last known value from the intermediate database together with its update time ("stock as of 14:20"). If there is no data, say plainly that 1C is not responding rather than showing zero.
  • Writes while 1C is down: accept the order into your own database, queue it, and tell the user it was accepted and will be passed to 1C. Retry with a growing pause and a cap on attempts.
  • Manual review: orders that still fail after all retries go to a separate list for an employee instead of vanishing.
  • Alerting: if the queue is growing, the person responsible should hear about it in Telegram before a customer calls. Monitoring is covered in support and monitoring after launch.
  • Telegram limits: the official bot FAQ advises avoiding more than about one message per second to a single chat and about 30 messages per second when broadcasting. After 1C recovers, send mass notifications through the queue at a steady pace, not in one burst.

Webhook or long polling, and where it all runs

A bot receives updates in one of two ways, and the choice does not depend on 1C. Production bots usually use a webhook on your server: Telegram sends the update and expects a 2xx status, and on any other status it repeats the request and gives up after a limited number of attempts. You can set a secret token, which Telegram puts in the X-Telegram-Bot-Api-Secret-Token header, so check it on entry. The two approaches are compared in webhook vs long polling.

An important consequence: the update handler must answer fast, and the heavy work with 1C must run separately through a queue. Otherwise a slow 1C answer triggers a redelivered update and you are back to duplicates.

Where to host the service depends on where 1C lives. If 1C is inside the company network, put an agent or the service in that same network: it calls 1C and your server itself, so no inbound connections from outside are needed.

When you do not need a bot for 1C

A bot is good when requests are frequent and short. If your staff open one report once a week, it is simpler to add that report to 1C or to a web interface. A bot is one more system to maintain, update alongside the configuration and secure.

Check yourself against this list before ordering one:

  • People sit in 1C at a computer all day and never ask anything in a messenger. A bot buys you almost nothing.
  • You need complex forms with dozens of fields and tables. A chat is awkward for that; a web form or a mobile app fits better. For such cases look at Telegram Mini Apps.
  • Nobody knows the 1C configuration well enough to fix an HTTP service. Without that person the integration stops at the first update.
  • If you still want a bot, begin with one scenario, for example stock and order status, and test it on real users. More on how we approach such projects is on the Telegram bot development page.
Questions

FAQ

Didn't find an answer — ask on the call or in Telegram.

How do you build a Telegram bot for 1C integration?

You need three parts: the bot itself, a service in between and an entry point into 1C. 1C publishes an HTTP service or OData on a web server, and the service stores the mapping of users to roles and calls 1C under a dedicated user with minimal rights. The bot only accepts commands and shows answers. Start with reading stock and statuses, and add writes later.

HTTP service or OData: which should I use to connect 1C to a Telegram bot?

Choose an HTTP service when you want a compact, ready answer and business logic kept in 1C, but you will need a configuration developer. OData suits quick reads of catalogues and documents as they are, with the answer assembled in your code. Per the documentation, OData is available from platform 8.3.5, so check your version and compatibility mode first.

Can a bot show 1C stock and order statuses in real time?

Yes, with a direct request to 1C, but then the bot's speed and availability equal those of 1C. More often stock is copied periodically into an intermediate database and shown with a timestamp. Keep a direct call where a second matters, and accept a delay of minutes for everything else.

How do I prevent duplicate orders when a bot creates them?

Give every write command a unique key, store it with the order and return the existing result on a repeat. Also pass an external identifier to 1C and look the document up by it before creating one. Then a redelivered update, a double tap and a network failure cannot create a second document.

What happens to the bot when 1C is down?

If the bot reads from an intermediate database it keeps answering and shows when the data was last refreshed. New orders go into a queue and reach 1C after recovery, and the user sees an honest status. Orders that fail after all retries land in a list for manual review, and the person responsible gets an alert.

How do I separate employee and customer permissions in a 1C bot?

Link a Telegram ID to an employee or counterparty in 1C through a one-time code or an invitation, and keep the role on your side. Check every action on the server against the role, filter customers strictly by their counterparty, and revoke access at once on dismissal. Never trust data inside buttons: it can be forged.

Related service

Telegram bot development for business

A bot is a way into your system in the place where customers and staff already talk. We build bots as full applications — with a database, permissions and integrations — not as a set of buttons.

Learn about the service
Other articles
Contact

Shall we discuss your task?

Thirty minutes on a call — and you understand the architecture, timeline and engagement format. No obligations.

Or message us on Telegram →Follow our Telegram channel →

Enter your Telegram or email so we can reply.

We reply within 15 minutes.