n8n

How to Automate MySQL Data Cleanup Alerts?

Keep your databases lean without manual work. The automation clears old received package records on a schedule and sends a Telegram message so your team knows the job is done. It suits operations teams that need clean data and quick updates.

Under the hood, a daily schedule at 8 AM runs two SQL update jobs, one for each MySQL database. You can also start it by clicking execute or by calling a webhook for on demand runs. After each database is cleaned, a Telegram message posts to your team chat to confirm the action. The flow connects a cron schedule, a webhook, two MySQL queries, and two Telegram messages. The result is faster queries, less storage waste, and clear visibility for your team.

To set it up, you need access to both MySQL databases and a Telegram bot added to your group. Expect to cut manual cleanup time from hours to minutes and keep systems running smoothly. It works well for warehouses, ecommerce, and logistics teams that manage many package entries and need routine data hygiene with clear proof of completion.

What are the key features?

  • Daily schedule at 8 AM runs cleanup without human input.
  • Manual execute and webhook trigger allow on demand runs.
  • Two MySQL queries target separate databases for the same policy.
  • Telegram messages confirm each database cleanup to the team chat.
  • SQL filter removes records older than one month in the received state.
  • Separate credentials for each database keep access organized.

What are the benefits?

  • Reduce manual cleanup from 2 hours to 2 minutes
  • Streamline data hygiene by 90 percent with a daily schedule
  • Improve data accuracy by removing stale records older than one month
  • Connect databases and team chat to create a simple audit trail
  • Lower storage and speed up reports by pruning old entries

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with MySQL and Telegram. See the Tools Required section above for links to create accounts with these services.
  3. In the n8n credentials manager, create two MySQL credentials. Name them clearly for each database. Enter host, port, database name, username, and password, and make sure the user has update permissions.
  4. Open each MySQL node and select the matching MySQL credential from the dropdown. Confirm the SQL statement matches your data model and retention policy in a test environment before running in production.
  5. Double click a Telegram node. In the credential field, click Create new credential, then paste your Telegram bot token. Repeat for the second Telegram node.
  6. Add the bot to your Telegram group and make sure it can post messages. Set the chatId to the group chat id. If messages do not appear, verify the bot is an admin and that the chat id is correct.
  7. Open the Cron node and confirm the run time. Adjust the hour to match your local time. Remember the n8n instance timezone controls the schedule.
  8. Open the Webhook node and copy the production URL. Send a test POST request to the path to trigger cleanup on demand. You can use curl or a simple HTTP client to verify it fires.
  9. Click Execute workflow to run a manual test. Watch the Telegram group for two confirmation messages and check your databases to confirm affected rows.
  10. Validate results by running a SELECT query before and after to confirm old records are updated as planned. Update the SQL time window if your policy changes.
  11. If the MySQL nodes fail, check firewall rules, database host, and user permissions. If Telegram messages fail, confirm the bot token and that the bot is in the target group.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

MySQL

Sign up

MySQL Community Edition (GPL) – Free ($0)

Telegram

Sign up

Free: $0, Telegram Bot API usage is free for developers

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.