Files
hoelee-blog/docs/linkedin/05-how-i-built-the-digikedai-telegram-bot.md
T

60 lines
4.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# LinkedIn Draft & Consultant Review: Architecting a 24/7 AI Support & Entitlement Engine Without Human-in-the-Loop
> **文档性质**:从 `blog.hoelee.com` 改写并在 NocoDB 排期的 LinkedIn 生产级动态。
> **发布状态**:`已通过外部顾问审阅 / NocoDB 已排期待发布`
> **排期波次**:Wave 2 (纵深期) - 槽位 5 (拟发布日期: 2026-11-12 Thu)
> **源文章**:https://blog.hoelee.com/posts/how-i-built-the-digikedai-telegram-bot/
> **系统标识**:`how-i-built-the-digikedai-telegram-bot` | **分类**:`case-studies`
> **字数**:2101 chars (严格控制在 3,000 字符内)
---
## 一、 核心背景与铁律约束提示(供复核对照)
1. **求职画像契合(Senior 全栈/DevOps/AI 架构师)**:彻底脱敏“做生意的老板/小公司创始人”倾向;一切商业实战均转换为“生产系统架构、高可用交付与自动化运维”视角。
2. **纯洁人设与零禁用词**:绝对禁止 `homelab`, `home lab`, `家用`, `小主机`, `玩具`, `折腾`, `玩票` 等词汇。必须使用 `the infrastructure I manage`, `my self-hosted production nodes`, `production host`。
3. **第一人称单数**:统一使用单数 `I` / `我`,杜绝虚张声势的复数 `we`。
4. **数据绝对保真**:所有数字、性能比率、吞吐提升、故障现象严禁凭空捏造。
5. **OPSEC 安全脱敏**:无内部绝对路径(如 `D:/dev`),无真实私有内网 IP,公网 IP 必须转为文档保留地址。
---
## 二、 LinkedIn 拟发布动态文案(已按顾问意见修订)
```text
Deploying an LLM as a customer-facing bot is easy. Building an autonomous system that provisions production account entitlements without hallucinating or granting unauthorized access is an entirely different engineering challenge.
I architected a 24/7 support and automated trial-provisioning engine running across Telegram and WhatsApp. The stack: TypeScript + Node 20, grammY in webhook mode behind a Hono HTTP server, a self-hosted LiteLLM gateway, and PostgreSQL for persistent state.
Three architectural boundaries keep it reliable in production:
1. Three-Tier Retrieval Over Context Stuffing
Dumping an entire service catalog into system prompts guarantees hallucinated specifications and prompt injection risks. Instead, the engine resolves intent through a strict hierarchy:
• Deterministic plan/SKU regex token matching (`/\b[A-Z]{2,}\d{2,}\b/gi`)
• Normalized keyword metadata filtering
• Targeted semantic retrieval with bounded context injection
2. State Machines Over Prompt Engineering
An LLM is fantastic at natural language disambiguation and terrible at transactional state. Actions that mutate state — tenant trial provisioning, entitlement issuance, verification — run on deterministic TypeScript state machines. The LLM only parses intent; it never touches the business transaction directly.
3. The Webhook Timeout Trap
Telegram aggressively re-delivers webhook updates if your server does not respond within a tight window. If an LLM generation takes 4 seconds, Telegram re-fires the webhook, spawning duplicate model calls and cascading into an infinite reply storm. The fix: immediately acknowledge the incoming payload with HTTP 200, dispatch generation to an async worker queue, and enforce idempotency locks on the `update_id`.
The system runs autonomously in production, backed by ~175 unit tests verifying state transitions, retrieval precision, and payload contracts.
How do you separate deterministic business logic from probabilistic model output in your production agent workflows?
Write-up: https://blog.hoelee.com/posts/how-i-built-the-digikedai-telegram-bot/
```
---
## 三、 外部顾问审阅评估反馈单与归档记录
- [x] **审阅结论**:需微调(已更新修订稿)
- **1. 诊断与修改批注**:求职红线防范:已按顾问修订稿消除电商副业色彩,强化 B2B 多租户权限开通与高可靠网关架构定位。
- **2. NocoDB 归档记录**:
- Candidate Key: `cand:how-i-built-the-digikedai-telegram-bot` (Status: `APPROVED`, Priority: `HIGH`)
- Draft Key: `cand:how-i-built-the-digikedai-telegram-bot:v1` (Status: `APPROVED`)
- 拟定发布节奏:每周 2 篇(周二/周四),平稳推进 5 周。