Automate Monthly Package Cleanup with n8n and MySQL

This workflow automates the monthly cleanup of outdated package records in two MySQL databases and sends Telegram notifications upon completion. It saves hours of manual database maintenance and ensures your shipment data stays accurate and up to date.
mySql
telegram
cron
+2
Workflow Identifier: 2382
NODES in Use: Manual Trigger, Cron, Telegram, Webhook, MySQL
Automate package cleanup with n8n and MySQL

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What this workflow does

This workflow automatically finds and marks old shipment packages as “DELETE” in two MySQL databases. It solves the problem of spending many hours manually cleaning package records that are a month old or more and have the status “TRANSPORTE-RECEBIDO”. After cleaning, it alerts the team with messages on Telegram, so everyone knows the task is done.


Who should use this workflow

This workflow is useful for managers and teams who work with multiple MySQL databases storing shipment package records. It helps users who want to reduce time spent on manual cleanup and avoid mistakes during deletion. It works well for companies needing real-time notifications about maintenance status.


Tools and services used

  • n8n workflow automation: Runs the full cleaning and notification process.
  • MySQL databases (PPM and OBJ): Two databases storing shipment package data.
  • Telegram Bot API: Sends notification messages to chat groups.
  • Cron scheduler: Automates workflow daily at 8 AM.
  • HTTP Webhook: Allows manual trigger from a URL.

How this workflow works

Inputs

The workflow starts from two triggers: a daily Cron at 8 AM and a manual HTTP Webhook call. Both trigger the package cleanup process.

Processing steps

  • It runs two SQL queries, one on each MySQL database (PPM and OBJ).
  • Each query finds package tokens where the module is “pacoteProduto”, the status is “TRANSPORTE-RECEBIDO”, and the date is older than 1 month.
  • For all these package tokens, it updates the module value to “DELETE”.
  • After each database update, the workflow sends a Telegram message confirming cleanup for PPM or OBJ.

Outputs

  • Package records with old status get marked for deletion in both databases.
  • Telegram messages are posted to the specified chat to notify about the cleanup events.

Beginner step-by-step: How to build this in n8n

Importing the workflow

  1. Use the Download button on this page to get the workflow file.
  2. In the n8n editor, click on “Import from File” and select the downloaded workflow.

Set up credentials and settings

  1. Add the MySQL credentials for the two databases, named PPM and OBJ.
  2. Set the Telegram Bot API credentials and enter the correct chat IDs for the notification nodes.
  3. Check the SQL queries in both MySQL nodes to confirm they match your database schema if needed.

Testing and activation

  1. Run the workflow once using “Execute Workflow” in n8n to test if packages get marked and Telegram messages arrive.
  2. If testing succeeds, activate the workflow toggle to enable automatic daily runs and webhook triggers.

Using self-host n8n is recommended for reliable operation in production.


Customizations

  • Change the time frame in the SQL query’s DATE_SUB interval to adjust how old packages need to be for cleanup (example: from “1 MONTH” to “2 MONTHS”).
  • Modify the Cron node’s scheduled hour to fit operational needs if 8 AM is not suitable.
  • Add extra Telegram nodes if notifying multiple chat groups or channels is required.
  • Alter SQL queries to archive or permanently delete records if company policies demand beyond marking with “DELETE”.

Common issues and fixes

  • MySQL syntax errors: Check for correct SQL commands and compatibility with your database version.
  • Telegram messages not delivered: Verify Telegram Bot API tokens and chat IDs for accuracy and expiration.
  • Webhook 404 errors: Confirm the webhook URL is copied correctly and the workflow is activated before testing.

Summary of results

✓ Packages older than 1 month with status “TRANSPORTE-RECEBIDO” get flagged for deletion automatically.

✓ Team members receive instant Telegram notifications after cleanup.

→ Reduced manual workload and improved accuracy in database maintenance.

→ Scheduled and manual triggers offer flexible workflow control.

Automate package cleanup with n8n and MySQL

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

The workflow starts by a daily Cron trigger at 8 AM or a manual HTTP Webhook trigger.
It finds packages with status “TRANSPORTE-RECEBIDO” older than 1 month and updates their module to “DELETE”.
It sends messages to a Telegram chat via the Telegram Bot API nodes connected after database updates.
Yes. The Cron node timing and Telegram chat IDs can be adjusted in the workflow to fit needs.

Promoted by BULDRR AI

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.