Skip to content

Commit 38506d1

Browse files
committed
fix(triggers): add paramVisibility, event-type filtering for Resend triggers
1 parent 62c0e7e commit 38506d1

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

apps/sim/lib/webhooks/providers/resend.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { getNotificationUrl, getProviderConfig } from '@/lib/webhooks/providers/
66
import type {
77
AuthContext,
88
DeleteSubscriptionContext,
9+
EventMatchContext,
910
FormatInputContext,
1011
FormatInputResult,
1112
SubscriptionContext,
@@ -100,6 +101,35 @@ export const resendHandler: WebhookProviderHandler = {
100101
return null
101102
},
102103

104+
matchEvent({ body, providerConfig, requestId }: EventMatchContext): boolean {
105+
const triggerId = providerConfig.triggerId as string | undefined
106+
if (!triggerId || triggerId === 'resend_webhook') {
107+
return true
108+
}
109+
110+
const EVENT_TYPE_MAP: Record<string, string> = {
111+
resend_email_sent: 'email.sent',
112+
resend_email_delivered: 'email.delivered',
113+
resend_email_bounced: 'email.bounced',
114+
resend_email_complained: 'email.complained',
115+
resend_email_opened: 'email.opened',
116+
resend_email_clicked: 'email.clicked',
117+
resend_email_failed: 'email.failed',
118+
}
119+
120+
const expectedType = EVENT_TYPE_MAP[triggerId]
121+
const actualType = (body as Record<string, unknown>)?.type as string | undefined
122+
123+
if (expectedType && actualType !== expectedType) {
124+
logger.debug(
125+
`[${requestId}] Resend event type mismatch: expected ${expectedType}, got ${actualType}. Skipping.`
126+
)
127+
return false
128+
}
129+
130+
return true
131+
},
132+
103133
async formatInput({ body }: FormatInputContext): Promise<FormatInputResult> {
104134
const payload = body as Record<string, unknown>
105135
const data = payload.data as Record<string, unknown> | undefined

apps/sim/triggers/resend/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export function buildResendExtraFields(triggerId: string) {
4848
placeholder: 'Enter your Resend API key (re_...)',
4949
description: 'Required to create the webhook in Resend.',
5050
password: true,
51+
paramVisibility: 'user-only' as const,
5152
required: true,
5253
mode: 'trigger' as const,
5354
condition: { field: 'selectedTriggerId', value: triggerId },

0 commit comments

Comments
 (0)