ChatPilot
Webhook Events
Idempotency guard table and deduplication query pattern.
webhook_events protects against duplicate provider retries.
Fields include event_type, external_id, and tenant_id. external_id maps to wa_message_id, mpesa_checkout_request_id, PayHero references, or another stable provider ID.
const existing = await db.webhookEvents.findUnique({where: {event_type_external_id: {event_type, external_id}}});