Sending Telegram Messages in SQL Statements

How to send telegram messages in SQL statements? SQLTelebot (also known as Telebot) is a plugin for SQLMessenger that allows you to send messages to Telegram chats, groups, or channels from your SQL statements. For example, you can use the following SQL command in your database to send an alert message to a Telegram group: INSERT INTO telebot_send_message (bot_id, chat_id, message_text) VALUES ( 7898095120, -- Your Telegram Bot ID '-1002546050440', -- The group Chat ID. To send messages to a channel, you can use the channel username, e.g., "@mychannel" 'Alert: Server 1 disk space critical - requires immediate maintenance.' -- The message content to be sent ); SQLTelebot supports the following database systems: SQL Server (2005 or higher) Oracle (11g or higher) MySQL (version 5.7.26 or higher) PostgreSQL (version 9.0 or higher) This article demonstrates how to send Telegram messages to a group "Report2" from a MySQL database. 1. Create the interface table in the MySQL database. Click here to download the SQL script for table creation. 2. Configure the database connection in SQLMessenger. Note: The "Database User Name" and "Default Database" used here must match the ones used when creating the interface table in Step 1. For detailed information about creating a database connection, please visit "DataSource Management". 3. Install the SQLTelebot plugin in SQLMessenger. *4. Create a Telegram bot. *(If you already have a bot, you can skip this step.) For complete instructions on Telegram bot creation, see: https://core.telegram.org/bots#how-do-i-create-a-bot. 5. Add the bot to the "Report1" group in Telegram. 6. Add the Telegram bot to SQLTelebot. Be sure to check the "Enable send messages via this bot" option. 7. Add the MySQL database to SQLTelebot as a monitored data source. Add the MySQL database to SQLTelebot as a monitored data source. In the Telebot Manager, click on "Interface Table Feature Configuration". Click "Add Data Source Monitoring". Select the data source "mysql-1" that created in Step 2, set the "Polling Interval", and then click "OK". After completing the above setup, SQLTelebot will check the telebot_send_message table in the mysql-1 database every 5 seconds for new records and send the messages accordingly. Now we insert a test record into "telebot_send_message": INSERT INTO telebot_send_message (bot_id, chat_id, message_text) VALUES ( 7898095120, /* Your Telegram Bot ID */ '-1002546050440', /* The group Chat ID. If you want to send messages to a channel, use the username like "@mychannel". */ 'This is a test message from MySQL!' /* The message content to be sent */ ); SQLTelebot will then send this message to the specified group. In addition to text messages, you can also use SQLTelebot to send images or files. For more details, please visit https://www.sqlmessenger.com/manual/plugin-2-interface-table-config.htm. Reposted from https://www.sqlmessenger.com/docreader.html?id=583

May 14, 2025 - 04:12
 0
Sending Telegram Messages in SQL Statements

How to send telegram messages in SQL statements?

SQLTelebot (also known as Telebot) is a plugin for SQLMessenger that allows you to send messages to Telegram chats, groups, or channels from your SQL statements.

For example, you can use the following SQL command in your database to send an alert message to a Telegram group:

INSERT INTO
    telebot_send_message (bot_id, chat_id, message_text)
VALUES
    (
        7898095120,        -- Your Telegram Bot ID
        '-1002546050440',  -- The group Chat ID. To send messages to a channel, you can use the channel username, e.g., "@mychannel"
        'Alert: Server 1 disk space critical - requires immediate maintenance.' -- The message content to be sent
    );

SQLTelebot supports the following database systems:

  • SQL Server (2005 or higher)

  • Oracle (11g or higher)

  • MySQL (version 5.7.26 or higher)

  • PostgreSQL (version 9.0 or higher)

This article demonstrates how to send Telegram messages to a group "Report2" from a MySQL database.

1. Create the interface table in the MySQL database. Click here to download the SQL script for table creation.

2. Configure the database connection in SQLMessenger.
Note: The "Database User Name" and "Default Database" used here must match the ones used when creating the interface table in Step 1.

Image description

For detailed information about creating a database connection, please visit "DataSource Management".

3. Install the SQLTelebot plugin in SQLMessenger.

Image description

*4. Create a Telegram bot. *(If you already have a bot, you can skip this step.)

Image description

For complete instructions on Telegram bot creation, see: https://core.telegram.org/bots#how-do-i-create-a-bot.

5. Add the bot to the "Report1" group in Telegram.

Image description

6. Add the Telegram bot to SQLTelebot.
Be sure to check the "Enable send messages via this bot" option.

Image description

7. Add the MySQL database to SQLTelebot as a monitored data source.
Add the MySQL database to SQLTelebot as a monitored data source.

  • In the Telebot Manager, click on "Interface Table Feature Configuration".

Image description

  • Click "Add Data Source Monitoring".

Image description

  • Select the data source "mysql-1" that created in Step 2, set the "Polling Interval", and then click "OK".

Image description

After completing the above setup, SQLTelebot will check the telebot_send_message table in the mysql-1 database every 5 seconds for new records and send the messages accordingly.

Now we insert a test record into "telebot_send_message":

INSERT INTO telebot_send_message
    (bot_id,
     chat_id,
     message_text)
VALUES (
    7898095120, /* Your Telegram Bot ID */
    '-1002546050440', /* The group Chat ID. If you want to send messages to a channel, use the username like "@mychannel". */
    'This is a test message from MySQL!' /* The message content to be sent */
);

SQLTelebot will then send this message to the specified group.

Image description

In addition to text messages, you can also use SQLTelebot to send images or files. For more details, please visit https://www.sqlmessenger.com/manual/plugin-2-interface-table-config.htm.

Reposted from https://www.sqlmessenger.com/docreader.html?id=583