Daily failed payment recovery from MySQL to HubSpot and Slack

By General Input

Every morning at 9am, turn yesterday's failed and declined charges in your billing database into HubSpot follow-ups for account owners and a single tidy Slack digest for the billing team.

Integrations

  • MySQL
  • HubSpot
  • Slack

Type

Agentic Task

Categories

  • Finance
  • Sales

Build me an agent workflow that recovers failed payments from my MySQL billing database every morning. Trigger: cron, daily at 9:00 AM in my local time zone.

Step 1. Pull the failures. Use MySQL Custom Query against my payments/transactions table to select every charge with a failed or declined status in the last 24 hours. Join to the customers table so each row also has: customer email, company name, plan name, monthly recurring revenue (MRR), date of the most recent successful charge, the failure code and human-readable reason, the HubSpot contact id if we already store one, and the account owner's name and email. Order by MRR descending. If the result set is empty, stop here and post nothing to Slack.

Step 2. For each failed payment, create a HubSpot follow-up. First use HubSpot Get Contact with idProperty=email to look up the contact by the customer's email address (skip this lookup if my database already stores the HubSpot contact id). Then use HubSpot Create Task with: subject in the form "Recover $<amount> from <company name>", a 2-3 sentence body that summarizes the situation (customer, amount, failure code and reason, plan, MRR, days since last successful charge, link back to the customer in our admin if I provide a URL pattern), due date = tomorrow at 9am local, status = NOT_STARTED, priority = HIGH when MRR is above a threshold I can tune (default $500/mo) and MEDIUM otherwise, assigned to the HubSpot owner whose email matches the account owner from the database (fall back to a default owner if no match), and associated with the matching HubSpot contact. Capture the returned task id and a deep link to the task in HubSpot for the Slack summary.

Step 3. Avoid duplicates. Before creating a new task, check whether the same contact already has an open task with a subject starting with "Recover $" created in the last 3 days. If yes, update that task instead (refresh the body and bump the due date) rather than stacking a second one.

Step 4. Post the daily summary. Use Slack Send a Message to post one message to #billing (let me change the channel). Open with a one-line header like "Failed payments overnight: N customers, $X at risk." Then a sorted list (highest MRR first) where each line shows: company name, plan tier, dollar amount, failure code in plain English, and a link to the HubSpot task. Keep it scannable, use Slack mrkdwn, and group enterprise-tier customers at the top with a small flag. If step 1 returned zero rows, do not post anything to Slack at all.

Inputs I should be able to configure at setup time: the MySQL table and column names for payments and customers, the MRR threshold for HIGH priority, the Slack channel, the default HubSpot owner email, the time zone, and an optional URL pattern for linking to the customer in our internal admin.

Quality bar: parameterize every MySQL query (use ? placeholders, never string-concatenate values), handle the empty-result case gracefully (silent on clean days), and write the Slack message and HubSpot task bodies in plain English a non-technical billing or CS teammate can act on in under a minute.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentWin back LiveChat visitors whose chats went unansweredTurn Mailjet email clicks into ranked HubSpot follow-upsiMessage campaign console with pre-flight checks and delivery boardChat quality review board for LiveChat support leadsA searchable RFP answer library your bid team drafts fromSee which target accounts just started advertising on LinkedInAccount health board that puts product usage next to your CRMLook up a customer's full chat history mid conversationLusha prospecting workbench with credit-safe reveals