Skillpedia
واجهات API والخوادم (backend)7.6k · #13164

integration-webhooks

ما الذي تفعله

تشرح هذه المهارة كيفية معالجة الرسائل الواردة من تكاملات الدردشة والبريد على الخوادم بلا خادم. يحفظ Webhook العمل ويرد فوراً، ثم يعالج تشغيل منفصل عمل الوكيل البطيء. وهي مخصصة للمطورين الذين يضيفون تكاملات مراسلة.

متى تستخدمها

  • ✓عندما تضيف تكاملاً جديداً للمراسلة مثل Slack أو WhatsApp.
  • ✓عندما تُسقط الرسائل من Webhook أو يُجاب عنها مرتين.
  • ✓عندما يستغرق رد الوكيل وقتاً أطول من نافذة الاستجابة للمنصة.

رابط المهارة

https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/integration-webhooks/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/integration-webhooks/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“هل يمكنك ربط تطبيقي بـ Slack حتى تُجاب الأسئلة في القناة دون انتهاء المهلة؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يخزّن Webhook الرسالة الواردة في قاعدة البيانات، ويعيد استجابة نجاح فوراً. ثم يعالج تشغيل منفصل الرسالة، وتبقى قاعدة البيانات المصدر الموثوق للحقيقة.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

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
الأسئلة الشائعة

لماذا لا يُشغَّل الوكيل داخل Webhook؟

تنص المهارة على أن منصات المراسلة تتوقع رداً سريعاً، وتشغيل الوكيل قد يستغرق وقتاً أطول كثيراً.

ماذا عن الرسائل المكررة؟

تخزين كل حدث أولاً يساعد على منع الحدث المعاد إرساله من تشغيل ثانٍ.

ما الطلب الذاتي الإرسال؟

هو طلب HTTP يرسله التطبيق إلى نفسه، فيُنفَّذ العمل البطيء في تنفيذ جديد.

التفاصيل

الوصف الأصلي من المؤلف

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

الشعبية

نجوم GitHub
7.6k
الترتيب
#13164
الترخيص
MIT
آخر تحديث
2‏/11‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة