{"id":41210,"date":"2025-12-10T17:35:23","date_gmt":"2025-12-10T14:35:23","guid":{"rendered":"https:\/\/trueconf.com/blog\/?p=41210"},"modified":"2025-12-15T13:15:27","modified_gmt":"2025-12-15T10:15:27","slug":"how-to-control-trueconf-server-using-its-api-and-telegram-bot","status":"publish","type":"post","link":"https:\/\/trueconf.com/blog\/knowledge-base\/how-to-control-trueconf-server-using-its-api-and-telegram-bot","title":{"rendered":"How to Control TrueConf Server Using Its API and Telegram Bot"},"content":{"rendered":"<a href=\"https:\/\/trueconf.com\/blog\/wp-content\/uploads\/2025\/12\/head_en.png\" data-rel=\"lightbox-gallery-f6mAdWni\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-41288\" src=\"https:\/\/trueconf.com\/blog\/wp-content\/uploads\/2025\/12\/head_en.png\" alt=\"\" width=\"1920\" height=\"1080\" loading=\"lazy\" title=\"\" srcset=\"https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/head_en.png 1920w, https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/head_en-690x388.png 690w, https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/head_en-1024x576.png 1024w, https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/head_en-768x432.png 768w, https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/head_en-1536x864.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">The administrator of <a href=\"https:\/\/trueconf.com\/products\/tcsf\/trueconf-server-free.html\" target=\"_blank\" rel=\"noopener\">TrueConf Server<\/a> can quickly access important server information using popular messengers, such as Telegram. This can be done by creating a bot that will retrieve the necessary data via the <a href=\"https:\/\/developers.trueconf.ru\/api\/server\/\" target=\"_blank\" rel=\"noopener\">TrueConf Server API<\/a>. The bot can be hosted locally on your own server or on any dedicated machine.<\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">In this example, we will demonstrate how to create a Telegram bot and deploy it on your local machine. We provide a ready-made example of task implementation using Python:<\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">\r\n<a href=\"https:\/\/github.com\/TrueConf\/Telegram-Bot-for-Control-TrueConf-Server\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"aligncenter wp-image-41289\" src=\"https:\/\/trueconf.com\/blog\/wp-content\/uploads\/2025\/12\/github.png\" alt=\"\" width=\"150\" height=\"44\" loading=\"lazy\" title=\"\" srcset=\"https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/github.png 954w, https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/github-690x203.png 690w, https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/github-768x225.png 768w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a><\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">The proposed bot has the following capabilities:<\/p>\r\n<ul class=\"ui-list ui-list--medium\" style=\"margin-bottom: 18px;\">\r\n \t<li class=\"ui-list__item ui-list__item--num\">Checking server status (running\/stopped).<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--num\">Retrieving the list of active conferences.<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--num\">Checking the number of online users.<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--num\">Finding and stopping long-running conferences that were left active by\r\nmistake.<\/li>\r\n<\/ul>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">In the following text, such mistakenly started conferences are referred to as &#8220;forgotten&#8221; for brevity, meaning they were not ended by the owner and moderators. For example, during a webinar, the guests left, but the moderator minimized the client application without stopping the event. It continues to run, and if recording was enabled, it unnecessarily occupies space on the SSD or HDD with a growing recording file.<\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">For example, we consider the following conference as &#8220;forgotten&#8221;:<\/p>\r\n\r\n<ul class=\"ui-list ui-list--medium\" style=\"margin-bottom: 18px;\">\r\n \t<li class=\"ui-list__item ui-list__item--disc\">it lasts longer than one hour;<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--disc\">only the owner or moderator remains in it;<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--disc\">it has participants, but none of them are moderators.<\/li>\r\n<\/ul>\r\n<a href=\"https:\/\/trueconf.com\/blog\/wp-content\/uploads\/2025\/12\/example1.png\" data-rel=\"lightbox-gallery-f6mAdWni\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"aligncenter wp-image-41290\" src=\"https:\/\/trueconf.com\/blog\/wp-content\/uploads\/2025\/12\/example1.png\" alt=\"\" width=\"350\" height=\"512\" loading=\"lazy\" title=\"\" srcset=\"https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/example1.png 1060w, https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/example1-321x470.png 321w, https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/example1-699x1024.png 699w, https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/example1-768x1124.png 768w, https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/example1-1049x1536.png 1049w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/a>\r\n\r\n<h2 id=\"prerequisites-for-launch\" class=\"h4--main h4--thick black-text ui-mb-xs-3 ui-mt-md-1\">Prerequisites for Launch<\/h2>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">For the successful launch of the bot, two conditions must be met:<\/p>\r\n\r\n<ul class=\"ui-list ui-list--medium\" style=\"margin-bottom: 18px;\">\r\n \t<li class=\"ui-list__item ui-list__item--disc\">Each monitored server must be accessible by its IP address or DNS name\r\nfrom the PC running the bot.<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--disc\">The PC with the bot must have internet access.<\/li>\r\n<\/ul>\r\n<div class=\"accent-note accent-note--line ui-mb-sm-1\">\r\n<p class=\"primary-medium-text\">The provided code is an example on which you can base your own bot implementation. Note that the bot&#8217;s security is ensured at the OAuth 2.0 protocol and HTTPS level, as well as on the network settings side (access rules, firewall, etc.). The bot operates in <b>long_polling<\/b> mode, independently polling the Telegram server for new updates. Unlike <b>webhook<\/b>, this connection scheme is completely secure in a corporate environment.<\/p>\r\n\r\n<\/div>\r\n<h2 id=\"registering-and-configuring-your-bot\" class=\"h5--main h5--thick black-text ui-mb-xs-3 ui-mt-md-1\">Registering and configuring your bot<\/h2>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">To use the Telegram bot, you will need the official <a href=\"http:\/\/t.me\/BotFather\">BotFather<\/a> bot.<\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">BotFather is the only bot that manages bots on Telegram. Read more in the <a href=\"https:\/\/core.telegram.org\/bots\" target=\"_blank\" rel=\"noopener\">official documentation<\/a>.<\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">To create a bot:<\/p>\r\n\r\n<ul class=\"ui-list ui-list--medium\" style=\"margin-bottom: 18px;\">\r\n \t<li class=\"ui-list__item ui-list__item--num\">Open <a href=\"http:\/\/t.me\/BotFather\">BotFather<\/a> and click <b>Run<\/b> or <b>Start<\/b>.<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--num\">A list of the bot&#8217;s commands will appear. You will need the <code>\/newbot<\/code> command. Click on it in the list or send a new message with <code>\/newbot<\/code> to the bot.\r\n<div class=\"accent-note accent-note--line ui-mb-sm-1\">\r\n<p class=\"primary-medium-text\">You can later access the list of available commands by clicking the <code>Menu<\/code> button or simply by typing <code>\/<\/code> in the message input field in the chat with BotFather.<\/p>\r\n\r\n<\/div><\/li>\r\n \t<li class=\"ui-list__item ui-list__item--num\">BotFather will then ask you to choose a name for your new bot. Come up with a name, for example, <code>TCS [name_org]<\/code>, where <code>[name_org]<\/code> is the name of your organization.<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--num\">Now, choose a username for your bot. The name <b>must<\/b> include the word <code>bot<\/code>, as it is a requirement from Telegram, for example, <code>server_[name_org]_bot<\/code>.\r\n<div class=\"accent-note accent-note--line ui-mb-sm-1\">\r\n<p class=\"primary-medium-text\">Please note that the bot&#8217;s name and its username are public identifiers that can be used to find it via global search.<\/p>\r\n\r\n<\/div><\/li>\r\n \t<li class=\"ui-list__item ui-list__item--num\">In response, you will receive a message containing information about the created bot and an access token for it via HTTP API in the following format:\r\n<pre class=\"default\">5032177032:AAGahjzZ6zbWSEsVFj13Ki-YMPhPEPzQjxE<\/pre>\r\nClick on the token in the message text to copy it to the clipboard. Then save it in a secure location, as you will need it later to use the bot.<\/li>\r\n<\/ul>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">To access your bot settings, use the <code>\/mybots<\/code> command and select the appropriate username. A menu will open where you can:<\/p>\r\n\r\n<ul class=\"ui-list ui-list--medium\" style=\"margin-bottom: 18px;\">\r\n \t<li class=\"ui-list__item ui-list__item--disc\">revoke the current token, and a new token is automatically generated;<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--disc\">edit name, welcome message, description, image;<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--disc\">add commands.<\/li>\r\n<\/ul>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">Now that the bot is configured, you can proceed to launch it.<\/p>\r\n\r\n<h2 id=\"preparing-the-configuration-file\" class=\"h4--main h4--thick black-text ui-mb-xs-3 ui-mt-md-1\">Preparing the configuration file<\/h2>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">First, you need to prepare a configuration file with the access data for your bot and server parameters.<\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">Copy the <code>settings.example.toml<\/code> file to a new file named <code>settings.toml<\/code>:<\/p>\r\n\r\n<pre class=\"shell\">cp settings.example.toml settings.toml<\/pre>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">Now you need to correctly fill in this data structure.<\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\"><b>tg-api-token<\/b> \u2014 Telegram HTTP API access token.<\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\"><b>tg-users-id<\/b> \u2014 Your numeric Telegram ID. Telegram ensures secure access to the bot using unique user IDs. Therefore, you will need to know your Telegram ID to receive a response from the bot. To obtain it, send any message to the bot <a href=\"http:\/\/t.me\/userinfobot\">@userinfobot<\/a>.<\/p>\r\n\r\n<div class=\"accent-note accent-note--line ui-mb-sm-1\">\r\n<p class=\"primary-medium-text\">If you want multiple people to have access to the bot, you can enter their IDs separated by commas.<\/p>\r\n\r\n<\/div>\r\n<b>locale<\/b> \u2014 The language code in which the bot will respond. You can edit phrases or add your translation in the\r\n<code>app\/locales<\/code> folder.\r\n<p class=\"primary-medium-text ui-mb-sm-1\">In <code>[servers.&lt;server_name&gt;]<\/code>, replace <code>&lt;server_name&gt;<\/code> with the preferred server name. It will be displayed in the button names:<\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">\r\n<a href=\"https:\/\/trueconf.com\/blog\/wp-content\/uploads\/2025\/12\/example2.png\" data-rel=\"lightbox-gallery-f6mAdWni\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"aligncenter wp-image-41291\" src=\"https:\/\/trueconf.com\/blog\/wp-content\/uploads\/2025\/12\/example2.png\" alt=\"\" width=\"350\" height=\"198\" loading=\"lazy\" title=\"\" srcset=\"https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/example2.png 920w, https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/example2-690x390.png 690w, https:\/\/trueconf.com/blog\/wp-content\/uploads\/2025\/12\/example2-768x434.png 768w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/a><\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\"><b>ip<\/b> \u2014 The FQDN or IP address of the server.<\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\"><b>client_id<\/b> and <b>client_secret<\/b> will be available to you after creating an OAuth2 application. For instructions on how to create one, refer to <a href=\"https:\/\/trueconf.com\/docs\/server\/en\/admin\/api\/\" target=\"_blank\" rel=\"noopener\">our documentation<\/a>.<\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">For our example, you will need to select the following permissions in the OAuth application:<\/p>\r\n\r\n<ul class=\"ui-list ui-list--medium\" style=\"margin-bottom: 18px;\">\r\n \t<li class=\"ui-list__item ui-list__item--disc\"><i>conferences<\/i>;<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--disc\"><i>users:read<\/i>;<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--disc\"><i>logs.calls:read<\/i>;<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--disc\"><i>logs.calls.participants:read<\/i>.<\/li>\r\n<\/ul>\r\n<p class=\"primary-medium-text ui-mb-sm-1\"><b>server_status.state<\/b> \u2014 enables or disables the automatic server availability check. Values: <code>true<\/code> or <code>false<\/code>.<\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\"><b>server_status.timeout<\/b> \u2014 the time in seconds after which the bot will check the server&#8217;s availability (Running, Disconnected). The default is set to 15 seconds, but you can enter your own value.<\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\"><b>ssl_certificate<\/b> \u2014 TLS certificate verification setting. If <code>true<\/code>, each server request will undergo verification. If your server uses a self-signed certificate, specify the path to it in this parameter (use a forward slash <code>\/<\/code>). If the bot is used in a trusted zone (for example, a server located in your corporate network and accessible only by you), specify <code>false<\/code> to disable certificate verification. If nothing is specified <code>\"\"<\/code>, it is equivalent to <code>false<\/code>.<\/p>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">After completing the file, you should have a structure similar to the example below:<\/p>\r\n\r\n<pre class=\"lang:toml decode:true\">tg-api-token = \"12345:example_key\"\r\ntg-users-id = [12345, 123456]\r\nlocale = \"ru\"\r\n\r\n[servers]\r\n\r\n[servers.\"video.example.com\"]\r\nip = \"video.example.com\"\r\nclient_id = \"86add683ebc98123968a549f8976db0024abe288\"\r\nclient_secret = \"b7f3f5cb51b02634b1bb546eb7f1f905c93960ba\"\r\naccess_token = \"a5bace995fd9d65315f36518fd7b3b4f68a69557\"\r\nssl_certificate = \"\"\r\n\r\n[servers.\"video.example.com\".server_status]\r\nstate = true\r\ntimeout = 15\r\n\r\n[servers.\"video.example.net\"]\r\nip = \"video.example.net\"\r\nclient_id = \"1ebb5498ddd6668d7885c1597f9a1330fc0caddd\"\r\nclient_secret = \"067171487c59f063287a44c40671d6247d647e42\"\r\naccess_token = \"\"\r\nssl_certificate = true\r\n\r\n[servers.\"video.example.net\".server_status]\r\nstate = 0\r\ntimeout = 15\r\n<\/pre>\r\n<h2 id=\"launching-the-bot\" class=\"h4--main h4--thick black-text ui-mb-xs-3 ui-mt-md-1\">Launching the bot<\/h2>\r\n<ul class=\"ui-list ui-list--medium\" style=\"margin-bottom: 18px;\">\r\n \t<li class=\"ui-list__item ui-list__item--num\">Install Python.<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--num\">Download the project. On the main page of the repository, click the\r\n<strong>Code \u2192 Download ZIP<\/strong> button and extract the downloaded archive.<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--num\">Install pipenv:\r\n<pre class=\"lang:default decode: true\">pip install pipenv<\/pre>\r\n<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--num\">Install the dependencies. To do this, run the following command in the\r\nterminal in the project folder:\r\n<pre class=\"lang:default decode: true\">pipenv install --python 3.x<\/pre>\r\nwhere <code>--python 3.x<\/code> is your Python version. We recommend using 3.7 and above.<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--num\">Start the bot:\r\n<pre class=\"lang:default decode: true\">pipenv run python3 main.py<\/pre>\r\n<\/li>\r\n<\/ul>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">When the bot is successfully launched, the terminal will display the message <b>Bot is running\u2026<\/b><\/p>\r\n\r\n<h2 id=\"deploying-the-bot-on-cloud-services\" class=\"h4--main h4--thick black-text ui-mb-xs-3 ui-mt-md-1\">Deploying the Bot on Cloud Services<\/h2>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">You can run your bot not only on a local machine but also in the cloud, which is convenient for continuous operation and accessibility from anywhere. For this purpose, you can use various cloud platforms that offer convenient tools for developing, testing, and deploying applications. Below, we list a few popular services where you can host your bot:<\/p>\r\n\r\n<ul class=\"ui-list ui-list--medium\" style=\"margin-bottom: 18px;\">\r\n \t<li class=\"ui-list__item ui-list__item--disc\"><b>Replit<\/b> is a service for running and developing applications directly in the browser.<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--disc\"><b>Heroku<\/b> is a platform for deploying and hosting applications with seamless integration with GitHub.<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--disc\"><b>Google Cloud Platform (GCP)<\/b> is a powerful platform with extensive capabilities for hosting and managing applications.<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--disc\"><b>AWS (Amazon Web Services)<\/b> is a cloud platform from Amazon for scalable applications with a multitude of tools and services.<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--disc\"><b>Microsoft Azure<\/b> is a platform for developing and managing applications in the cloud with integration into the Microsoft ecosystem.<\/li>\r\n \t<li class=\"ui-list__item ui-list__item--disc\"><b>Glitch<\/b> is a service for quick hosting and app development with a simple interface and GitHub integration.<\/li>\r\n<\/ul>\r\n<p class=\"primary-medium-text ui-mb-sm-1\">These services allow you not only to deploy a bot but also to scale it easily and ensure its availability to users anywhere in the world.<\/p>","protected":false},"excerpt":{"rendered":"The administrator of TrueConf Server can quickly access important server information using popular messengers, such as Telegram. This can be done by creating a bot that will retrieve the necessary data via the TrueConf Server API. The bot can be hosted locally on your own server or on any dedicated machine. In this example, we [&hellip;]","protected":false},"author":55,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[260],"tags":[246],"class_list":["post-41210","post","type-post","status-publish","format-standard","hentry","category-knowledge-base","tag-api-and-sdk","no-wpautop"],"_links":{"self":[{"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/posts\/41210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/users\/55"}],"replies":[{"embeddable":true,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/comments?post=41210"}],"version-history":[{"count":18,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/posts\/41210\/revisions"}],"predecessor-version":[{"id":41293,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/posts\/41210\/revisions\/41293"}],"wp:attachment":[{"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/media?parent=41210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/categories?post=41210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/tags?post=41210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}