Urgent.News

What's breaking now, across thousands of outlets.

AI

I Built an AI Pipeline That Reads Support Emails and Drafts Replies (Here's What Actually Broke, and the Math on Whether It's Worth It)

I run a one-person dev shop, and I keep hearing the same complaint from small business owners: answering customer support emails eats hours every day, especially when half the questions are variations of the same five things. So I built a small pipeline: Gmail → Claude API classification → Slack notification with a drafted reply → human approves or edits before anything goes out. This post covers…

A small one-person development company faced the common problem of support agents spending excessive time answering repetitive customer inquiries. To address this, the developer built a pipeline that uses Gmail, Claude's API for classification, and Slack notifications to automate the process. The pipeline pulls unread messages from Gmail, extracts the message body while handling various formats, classifies the email with structured output from Claude, routes the email to a human based on the category and confidence score, generates a draft reply using the same API call, posts a Slack card with the information, marks the email as read, and stores the result in SQLite for future runs.

The developer faced several unexpected issues while implementing the pipeline. The first bug was related to OAuth scopes. Initially, the developer used both gmail.readonly and gmail.send scopes, but adding the mark as read step required write access. Google silently dropped the redundant scope, causing the token refresh to fail without any clear indication. To avoid this issue, it is essential to request the narrowest single scope that covers all necessary actions.

The second bug occurred while extracting the message body from Gmail messages, which are frequently multipart/alternative structures containing both plain text and HTML parts. The developer's initial approach recursively searched for plain text and fell back to HTML if it wasn't found. However, if the HTML part appeared before the plain text part in the tree structure, the function incorrectly returned the HTML version.

To resolve this issue, the developer implemented two separate passes searching for plain text first, and only if that fails, proceeding to search for HTML. This approach ensures that the preferred format is found, and the fallback is only triggered if the preferred format is absent throughout the entire structure.

The third bug was related to the routing process based on category and confidence score. Initially, the developer assumed a simple lookup table for assigning emails to specific human handlers based on the category. However, a test case revealed an exception to this rule: if the model's confidence score was below a certain threshold, the email would be routed to a broader category handler, regardless of its category.

To address this issue, the developer modified the routing logic to account for the confidence threshold. Emails with lower confidence scores are assigned to a person with broader context, while those with higher confidence scores follow the category-based routing table.

In summary, the developer's pipeline successfully automates the process of answering customer support emails by utilizing Gmail, Claude's API for classification, and Slack notifications. However, the developer encountered three unexpected bugs during implementation: an OAuth scope trap, issues with handling multipart/alternative message bodies, and a routing error based on confidence thresholds.

By understanding and addressing these issues, the developer was able to create an efficient and reliable system for managing customer support inquiries.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

Versioning your agent configs: stop treating instructions as disposable

Nobody versions their agent configs, and everybody pays for it. The config files that steer AI agents in your repos are infrastructure: they change behavior, they break silently, and they interact…

  • Treat AI agent configurations like critical infrastructure
  • Apply semantic versioning to config sets
  • Create compatibility records for external tool versions

I Let AI Write My Tests for 6 Months. Here Is What Actually Survived Production

Last month a teammate pasted a Playwright test into our PR channel and wrote "AI generated this in 4 seconds, why are we still writing tests by hand." The test passed. It also asserted nothing.

  • AI generates failing tests from bug reports, saving 60% of initial work
  • AI explains flaky tests, suggesting possible reasons for failures
  • AI suggests stable locators, improving test maintainability

AI Data Centers: Engineering High-Density Infrastructure and Grid Demands

AI Data Centers: Engineering High-Density Infrastructure and Grid Demands Modern artificial intelligence workloads require fundamentally different physical, electrical, and thermal infrastructure than…

  • AI workloads demand high-density infrastructure with 40-100 kW rack power consumption
  • AI nodes rely on specialized vector engines and high-bandwidth memory stacks
  • Constructing AI facilities requires redesigning power distribution and cooling systems

More from Saturday 19 September →