integration-webhooks
Skill này làm gì
Skill này giải thích cách xử lý tin nhắn đến từ các tích hợp chat và email trên máy chủ serverless. Webhook lưu công việc, trả lời ngay, còn một lần chạy riêng thực hiện phần việc chậm của agent. Skill dành cho lập trình viên thêm tích hợp nhắn tin.
Khi nào nên dùng
- ✓Khi bạn thêm một tích hợp nhắn tin mới như Slack hoặc WhatsApp.
- ✓Khi tin nhắn từ webhook bị mất hoặc được trả lời hai lần.
- ✓Khi câu trả lời của agent mất nhiều thời gian hơn cửa sổ phản hồi của nền tảng.
Liên kết skill
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/integration-webhooks/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Bạn có thể kết nối ứng dụng của tôi với Slack để các câu hỏi trong kênh được trả lời mà không bị timeout không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Webhook lưu tin nhắn đến vào cơ sở dữ liệu và trả về phản hồi thành công ngay. Một lần chạy riêng sau đó xử lý tin nhắn, và cơ sở dữ liệu vẫn là nguồn sự thật.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Integration Webhooks
Rule
Integration webhooks (Slack, Telegram, WhatsApp, email, Google Docs, etc.) must enqueue work to SQL and return 200 immediately, then process the work in a separate fresh function execution kicked off by a self-fired HTTP POST. SQL is always the source of truth. Long-lived hosts use an in-process retry loop as a best-effort safety net; serverless deployments must use an external durable sweep when recovery cannot depend on a process staying alive.
Do not run agent loops inside the webhook handler itself. Do not rely on
fire-and-forget Promises after returning from a serverless handler — they get
killed when the function freezes.
Why
Messaging platforms expect a 200 response within a tight window — Slack will retry after 3 seconds, and a retried event triggers duplicate agent runs. At the same time, an agent loop replying to the message can take 30–60+ seconds because it may make multiple LLM calls and tool calls.
Past attempts that don't work cross-host:
- Fire-and-forget
Promise.then(...)after returning — Lambda/Vercel/CF freeze the execution context the moment the response goes out. The promise is silently killed, the user gets no reply, and there's no error in the logs. - A platform background function as the queue — host-specific execution is useful as a delivery mechanism, but it cannot replace the SQL row or atomic claim shared by every host.
- Cloudflare
event.waitUntil()— CF Workers only, not portable. - Vercel Fluid /
after()— Vercel-only, gated behind specific runtimes. - A long-lived in-process queue — fine on a single Node box, but on serverless every cold start gets a fresh queue and any pending work is lost.
The only universal answer: persist the work, then trigger a brand new function execution to do it. SQL is the queue, a self-webhook is the trigger, and a recurring job is the safety net.
The Flow
┌──────────┐ 1. POST /integrations/:platform/webhook
│ Platform │────────────────────────────────────────────►┌──────────────────┐
└──────────┘ │ Webhook handler │
│ (function exec 1)│
└──────────────────┘
│
2. INSERT INTO integration_pending_tasks
(status='pending', payload=...)
│
3. dispatch POST /integrations/process-task
— portable self-fire by default
— acknowledged background handoff when enabled
│
4. return 200 to platform ◄───────────┘
┌──────────────────┐
5. POST arrives at processor │ Processor │
(separate fresh function) │ (function exec 2)│
└──────────────────┘
│
6. claimPendingTask(id) → status='processing'
7. runAgentLoop(...) — full timeout budget here
8. adapter.sendResponse(...) back to platform
9. markTaskCompleted(id)
┌──────────────────────────────────────────────┐
│ Recovery sweep (every 60s) — safety net │
│ Re-fires processor for tasks stuck in │
│ 'pending' or 'processing' beyond timeout. │
│ Caps retries at 3 then marks 'failed'. │
└──────────────────────────────────────────────┘
The webhook handler does as little as possible. The fresh function execution
that handles _process-task gets its own full timeout budget for the agent
loop.
Key Files
| File | Purpose |
|---|
Câu hỏi thường gặp
Vì sao không chạy agent ngay trong webhook?
Skill nói các nền tảng nhắn tin mong đợi phản hồi nhanh, còn một lần chạy agent có thể mất lâu hơn nhiều.
Còn tin nhắn trùng lặp thì sao?
Lưu từng sự kiện trước giúp ngăn một sự kiện được thử lại kích hoạt thêm một lần chạy.
Yêu cầu tự kích hoạt là gì?
Đó là một yêu cầu HTTP theo dõi mà ứng dụng gửi cho chính nó, để công việc chậm chạy trong một lần thực thi mới.
Chi tiết
Mô tả gốc của tác giả
Cross-platform pattern for handling messaging integration webhooks (Slack, Telegram, WhatsApp, email, etc.) on serverless hosts. Use when adding a new integration adapter, debugging dropped messages, or wiring long-running agent work into a webhook handler.
repo: BuilderIO/agent-native
Độ phổ biến
- Sao GitHub
- 7.6k
- Vị trí xếp hạng
- #13164
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
design-exploration
7.6kGiúp agent của bạn khám phá nhiều hướng thiết kế giao diện song song, để bạn chọn một hướng rồi tinh chỉnh thiết kế đã chọn.
visual-edit
7.6kGiúp agent của bạn mở một ứng dụng cục bộ đang chạy trong trình chỉnh sửa trực quan, để bạn xem và sửa các màn hình thật cùng nhau.
turn-into-app
7.6kBiến quy trình, bảng tính hoặc dự án thành ứng dụng trực quan có màn hình đầy đủ dữ liệu, với agent làm việc phía sau các điều khiển.
visual-plan
7.6kBiến một kế hoạch viết bằng văn bản thuần thành kế hoạch trực quan tương tác, có sơ đồ, bản đồ file, đoạn code và các câu hỏi còn mở.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.