Slack Webhook Payload Schema Validation Prompt
Add strict schema validation to a Slack-bound webhook receiver so malformed or unexpected inbound payloads are rejected cleanly instead of crashing the handler or posting garbage into channels.
- Target user
- Engineers building Slack ChatOps integrations and webhook receivers
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior platform engineer who builds Slack integrations and has watched an upstream tool quietly change its webhook shape and break a channel feed at 2am. I will provide: - A sample of the inbound webhook payload(s) we receive (from Grafana, CI, a SaaS tool, etc.) - Our receiver runtime/framework and how it currently parses the body - What we do with the payload (format a Block Kit message, route by field, etc.) Your job: 1. **Derive a schema** — from my samples, write an explicit schema (JSON Schema or runtime validator) for required fields, types, enums, and optional fields, with sane bounds on string lengths and array sizes. 2. **Validate before use** — show the receiver validating the parsed body up front and rejecting non-conforming payloads with a structured error, before any field is touched. 3. **Fail safe, not loud** — on validation failure, log the rejection with a payload fingerprint and return the correct HTTP status; never post a half-built or `undefined`-laden message into Slack. 4. **Tolerate additive change** — allow unknown extra fields (forward-compatible) but reject missing required ones, so upstream additions don't break you. 5. **Sanitize for Slack** — strip or escape content that would break mrkdwn or inject unwanted @here/@channel mentions before it reaches a message. 6. **Test fixtures** — provide valid, missing-field, wrong-type, and oversized fixtures and assert each is handled. Output as: (a) the schema definition, (b) the validation middleware/guard code, (c) the failure-path handler and log shape, (d) the Slack-content sanitization step, (e) the test fixtures and assertions. Default to rejecting anything that doesn't match the schema; it is safer to drop one malformed event than to flood a channel with broken or injected messages.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Slack Block Kit Modal Input Validation & Error Display Prompt
Design server-side validation for Block Kit modals — response_action errors, per-input error keying, cross-field rules, and re-render UX that never loses user input.
-
Slack Bot Blue-Green Deployment Cutover Prompt
Design a blue-green deployment for a Slack app so you can ship a new bot version with zero dropped events, no duplicate handling, and a fast rollback if interactivity breaks.
-
Slack postMessage Idempotency & Safe Retry Prompt
Make chat.postMessage delivery idempotent so retries after timeouts or crashes never double-post alerts, and a redelivered event never spams a channel twice.
-
Slack App Cold-Start & 3-Second Ack Latency Optimization Prompt
Diagnose and fix Slack app latency that breaks the 3-second ack budget — serverless cold starts, sync work in handlers, and defer-then-followup patterns.
More Slack prompts & error guides
Browse every Slack prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.