Route Sentry errors to the right CSM in Slack
When a new error fires, check whether any paying customers are affected, then ping the right CSM in Slack and log the incident on each contact in HubSpot.
Build me an agent workflow that routes Sentry errors to the right customer success manager when a paying customer is actually affected. The trigger is a Sentry issue alert webhook (do not poll Sentry — its common docs explicitly warn that polling will rate-limit you). I will configure a Sentry alert rule to POST to the workflow's webhook URL whenever an issue fires.
When the webhook fires, the agent should:
1. Pull the issue ID out of the Sentry alert payload and call Sentry's Retrieve an Issue to get the title, culprit, project, environment, level, event count, users affected count, first-seen, last-seen, and the issue's permalink. Then call List an Issue's Events for that issue (limit to the most recent ~25 events, optionally bounded by a recent time range) and collect every distinct user email and user ID from the events' user context. Sentry stores user identity as tags on events (user.email, user.id), so the agent has to walk the events, not just the top-level issue payload. De-duplicate by email before doing any CRM lookups.
2. For each unique email, call HubSpot's Get Contact with idProperty=email (fall back to Search Contacts if Get Contact 404s) and request the contact's lifecycle stage, hubspot_owner_id, and associations to companies and deals. For matched contacts, also resolve the associated company (Get Company) and the contact or company owner (Get Owner) so we can name the CSM. If you need to confirm whether the account has an open or closed-won deal, look at the contact's associated deals.
3. Apply a customer filter. Default rule: a contact counts as a paying customer if lifecycle stage is 'customer' AND the contact (or its company) has an owner assigned. Optionally also count contacts whose company has an open deal or a closed-won deal. Make the filter logic easy for me to tweak later. If zero unique impacted users pass the filter, the agent should stop here and post nothing — silence is the desired behavior when no paying account was hit.
4. If at least one paying customer is impacted, use Slack Bot's Send a Message to post a single message to our customer-success Slack channel (channel ID should be a configurable parameter). The message should summarize the Sentry error (title, project, environment, level, event count, users-affected count), list each impacted account as 'Company name — contact email — lifecycle stage', tag the HubSpot owner of each account as the CSM to follow up (look up the owner's Slack user by email via the Slack Bot users.lookupByEmail capability so we can @-mention them, and fall back to plain text 'CSM: Owner Name' if no Slack user matches), and include the Sentry issue permalink. Format the message in Slack mrkdwn, not standard Markdown.
5. For every impacted HubSpot contact, call HubSpot's Create Note with a short body recording that this Sentry incident touched the account ('Affected by Sentry issue <title> in <project> on <date>. Link: <permalink>.'), and associate the note with that contact. This way the account history reflects the incident even after the Slack thread scrolls off.
Other behavior I want:
• De-dupe Slack posts for the same Sentry issue: if the same issue ID has already produced an alert in the last 24 hours, post a single threaded follow-up to the existing message instead of starting a new top-level alert, so a noisy issue does not spam the channel.
• If an event has a user ID but no email, skip it gracefully and note it in the run log. Do not block the alert.
• If the issue affects users who are not in HubSpot at all, count them but do not call them paying customers.
• Keep all the tunable bits (Slack channel, customer-filter definition, how many events to scan, which Sentry environments to act on) as named parameters at the top of the workflow so I can adjust them without rewriting the instructions.
Integrations: Sentry (issue alert webhook trigger plus Retrieve an Issue and List an Issue's Events), HubSpot (Get Contact, Search Contacts, Get Company, Get Owner, Create Note), Slack Bot (Send a Message, and user lookup by email for @-mentions).
Additional information
What does this prompt do?
- Listens for new Sentry issue alerts from your alert rules so you find out about errors the moment they happen.
- Looks up every user attached to recent error events, checks them against your HubSpot CRM, and figures out which ones are paying customers.
- Posts a single, focused Slack message in your customer-success channel naming the impacted accounts and tagging each account's owner as the CSM to follow up.
- Logs a note on every impacted contact in HubSpot so the account history shows that the incident touched them.
- Stays silent when no paying customers were affected so the channel only lights up when it actually matters.
What do I need to use this?
- A Sentry account with permission to create issue alerts that send to a webhook.
- A HubSpot account with contacts, companies, deal pipelines, and owners set up the way your team uses them.
- A Slack workspace and a customer-success channel where the alerts should land.
How can I customize it?
- Change what counts as a customer (for example, lifecycle stage equals customer, or any open or closed-won deal on the contact's company).
- Swap the Slack channel, change the message format, or DM the account owner directly instead of posting to a shared channel.
- Adjust how many recent events to scan, or limit alerts to specific Sentry projects, environments, or error levels.
Frequently asked questions
What happens if no paying customers are affected?
How does it know which CSM to tag?
What if the same person hits the error a hundred times?
Will this work if my errors do not carry a user email?
Can I change what counts as a 'paying customer'?
Stop finding out about customer-impacting bugs from the customer.
Connect Sentry, HubSpot, and Slack once, and Geni pages the right CSM the moment a paying account hits an error.