Back to Prompts
Package 4 prompts

Webhooks Prompts

AI prompts for webhooks from the LearnWithHasan AI Coding Building Blocks (Architecture).

#1 Coding Assistant

Create a Webhook Endpoint

Start here - simplest webhook pattern From the Webhooks AI Coding Building Block.

Prompt
Create a simple webhook endpoint that receives notifications from an external service.

Framework: [Express, Flask, Django, FastAPI, etc.]
Service: [Stripe, GitHub, Shopify, or describe what's sending webhooks]

Keep it simple:
1. Create a POST endpoint at /webhooks/[service-name]
2. Parse the incoming JSON payload
3. Log what was received (for testing)
4. Return a 200 OK response quickly

I want to understand the basic pattern first. Show me:
- The endpoint code itself (keep it short!)
- How to read the event type (e.g., "payment.succeeded")
- How to access the event data (e.g., customer email, amount)
- What response to send back

I'm learning, so explain each part simply.
#2 Coding Assistant

Verify Webhook Signatures

Essential security - verify webhook authenticity From the Webhooks AI Coding Building Block.

Prompt
Add signature verification to my webhook endpoint. I want to make sure the webhook is actually from [Stripe/GitHub/the service] and not a fake request.

Framework: [Express, Flask, Django, FastAPI, etc.]
Service: [Stripe, GitHub, Shopify, etc.]

Requirements:
1. Get the signature from the request headers
2. Verify it matches the expected signature
3. Reject requests with invalid signatures (return 401)
4. Only process the webhook if verification passes

Show me:
- Where to find my webhook signing secret (in the service dashboard)
- How to compute the expected signature
- How to compare signatures securely (timing-safe comparison)
- What to log when verification fails (for debugging)

Security matters here. Explain why signature verification is needed and what could go wrong without it.

I'm learning, so explain each part simply.
#3 Coding Assistant

Handle Payment Webhooks

Common use case - payment processing From the Webhooks AI Coding Building Block.

Prompt
Create a complete payment webhook handler for Stripe. I want to handle successful payments and failed payments properly.

Framework: [Express, Flask, Django, FastAPI, etc.]

Handle these events:
1. payment_intent.succeeded - Payment was successful
2. payment_intent.payment_failed - Payment failed
3. customer.subscription.created - New subscription started
4. customer.subscription.deleted - Subscription cancelled

For each event:
- Log what happened
- Update my database (show placeholder code)
- Send appropriate emails (show where I would call my email service)

Also show me:
- How to handle events I don't care about (ignore gracefully)
- How to avoid processing the same event twice (idempotency)
- How to respond quickly so Stripe doesn't timeout

I'm learning, so explain each part simply.
#4 Coding Assistant

Explain Existing Webhook Code

Understand existing webhook code From the Webhooks AI Coding Building Block.

Prompt
I have some webhook code but I don't fully understand what it's doing. Please explain it to me in simple terms.

Here's the webhook code:
[paste your webhook code here]

Please explain:
1. What events does this webhook handle? (one sentence each)
2. Walk through it line by line: what happens at each step?
3. How does it verify the webhook is authentic?
4. What happens if something goes wrong?
5. Are there any security concerns or missing pieces?

Also suggest improvements if you see:
- Missing signature verification
- No idempotency handling
- Slow operations that might cause timeouts
- Missing error handling

I'm learning, so explain each part simply.
33 views