Skip to content

Connected Telegram Bots

The register of bots running for your company: a record is a bot of one of the pluggable types, with its own token, user list and command permissions. There is one bot of each type per server: an enabled record of the same type in another company of the database replaces it, and a disabled record of the same type can stop it when the server restarts — keep one record per type.

Where to find it: Modules → System → Registers → Connected Telegram Bots

A worked example

Connected Telegram bots

The list is empty in the demo company: bots need a real Telegram token, and none were set up here. A bot's card has three parts:

  • the passport: name, description, the Telegram access token, and the "Bot is disabled" and "Public bot" flags;
  • users — who has access: an ERP login and their Telegram id, filled in automatically from the user's card;
  • permissions — which commands and menu buttons a particular Telegram account may use.

The two matrices are not duplicates: the first answers "who are you", the second "what may you do".

Who may write to the bot

The work-request bot (wash_up) is currently switched off in the program itself until its dialogs are reworked: a record of this type does not start even with a token and without the "Bot is disabled" flag. Such a record with a token and without the flag cannot be saved: the save is refused with "The "wash_up" Telegram bot is disabled: its dialogs must be reworked before use". Tick "Bot is disabled" or remove the token and the record saves; such a record does not stop other records of the register from being saved. The user and permissions matrices are read by wash_up (it answered only the Telegram ids in the user matrix), and the user matrix also by online booking, which sends its new-booking notices through the wash_up bot. So for now these matrices affect no bot at all.

The order-status bot (status_bot) is meant for customers and does not read the user matrix: it answers anyone, but links a customer to a chat only by their own number — the one sent with the "Відправити свій номер телефону" button. It does not accept someone else's contact card or a number typed by hand: otherwise a stranger would receive the status of other people's orders.

The "Public bot" flag has no part in this: it is stored on the card, but the bot start-up code never reads it. It is a note for people, not a setting — the bot behaves the same either way.

The "Bot is disabled" flag does work: the bot gets no token and never starts, while its token and permissions stay intact. A change to the card (the token, this flag) is picked up at once: the save restarts the bots with what it has just written.

Typical situations

The bot does not answer. Check the "Bot is disabled" flag, the token (Telegram will not let the bot in without one) and the bot type: wash_up does not start at all for now.

A member of staff writes to the request bot and it stays silent. The wash_up bot is currently switched off in the program — it answers nobody, whatever the user matrix holds.

A command needs restricting. The permissions matrix has one row per user-and-command pair: if a user has at least one row, only the listed commands are open to them; with no rows, all are. It applies only to wash_up, which is switched off for now; status_bot has no menu commands.

Where to look next