Skip to content
Notifications
Clear all

Just built a Slack bot that posts weekly Helicone spend summaries.

4 Posts
4 Users
0 Reactions
5 Views
(@devops_shift_lead)
Estimable Member
Joined: 4 months ago
Posts: 136
Topic starter   [#439]

Wanted better visibility into our LLM API costs without another dashboard to check. Built a Slack bot that parses Helicone's weekly summary email and posts the key metrics to our #infra-spend channel.

The bot is just a Cloud Function triggered by a Pub/Sub subscription. It uses the Gmail API to find the Helicone email, extracts the data with some regex, and formats a Slack message. Takes the weekly email and makes it actionable in the channel where the team already is.

Key parts of the config:

```yaml
# cloudbuild.yaml excerpt for the function deploy
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args:
- functions
- deploy
- helicone-slack-summary
- --trigger-topic=helicone-weekly-email
- --runtime=python311
- --region=us-central1
```

The parsing logic is straightforward. The Helicone email has a consistent format, so we grab:
* Total cost for the week
* Cost by provider (OpenAI, Anthropic, etc.)
* Top 5 most expensive requests (with user IDs anonymized)
* Week-over-week change percentage

Result is a clean Slack message that triggers our weekly cost review. Catching drift early has already saved us from a few runaway experiments.

-shift


shift left or go home


   
Quote
(@martech_ops_sarah)
Trusted Member
Joined: 4 months ago
Posts: 30
 

Love this approach! We did something similar but with the Helicone webhook API directly to get daily spends. That weekly email is super reliable though - regex on a consistent format is way less brittle than maintaining API clients sometimes.

Did you have to handle any encoding weirdness with the email body? We ran into a few cases where the cost numbers got split across lines in the HTML, which broke our initial pattern matches. Ended up with a two-pass cleanup.

It's a small thing, but adding a link from the Slack summary back to the Helicone dashboard for the folks who *do* want to dive deeper has been really appreciated by our data team.


Data is the new oil


   
ReplyQuote
(@saas_switcher_elle_fresh)
Eminent Member
Joined: 2 months ago
Posts: 20
 

Great point about the link back to the dashboard. I'd totally overlooked that. Making it actionable in Slack but also giving a one-click path to more detail is a smart combo.

On the encoding weirdness, we definitely saw some line breaks too. I found stripping all the HTML tags first and then collapsing whitespace made the regex way more reliable. Honestly, the consistent format of those weekly emails is a lifesaver compared to some other vendors.



   
ReplyQuote
(@procurement_pro_2025)
Active Member
Joined: 4 months ago
Posts: 10
 

Good call on the weekly cadence. Drift detection is the primary value here. Catching runaway experiments before the monthly bill lands is a solid 80/20 win.

Have you considered adding a simple threshold check to your function? If the WoW change exceeds, say, 15%, have it flag the message with @here in the channel. We found that automated urgency beats relying on someone to read the summary and decide to act.

The anonymized user IDs are smart for internal sharing. Just be sure your legal team is aligned if those IDs could be considered PII in your jurisdiction.


page 18 is where the traps are


   
ReplyQuote