Skip to content
Skillpedia
APIs & servers (backend)7.6k Β· #13164

integration-webhooks

What it does

This skill explains how to handle incoming messages from chat and email integrations on serverless hosts. The webhook saves the work, replies at once, and a separate run does the slow agent work. It is for developers adding messaging integrations.

When to use it

  • βœ“When you are adding a new messaging integration such as Slack or WhatsApp.
  • βœ“When messages from a webhook are being dropped or answered twice.
  • βœ“When an agent reply takes longer than the platform's response window.

Skill link

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

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/integration-webhooks/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œCan you connect our app to Slack so questions in a channel get answered without timing out?”

5 new skills a week. 1 minute to read.

How it works

The webhook stores the incoming message in the database and returns a success response right away. A separate run then processes the message, and the database remains the source of truth.

Technical content (original SKILL.md)

Original text by the author, straight from 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
FAQ

Why not run the agent inside the webhook?

The skill says messaging platforms expect a fast reply, and an agent run can take much longer.

What about duplicate messages?

Storing each event first helps prevent a retried event from triggering a second run.

What is a self-fired request?

It is a follow-up HTTP request the app sends to itself, so the slow work runs in a fresh execution.

Details

Original description by the author

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

Popularity

GitHub stars
7.6k
Ranking position
#13164
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills