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

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

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

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.

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 Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free