I'm using hono to process http requests - as per your blog post, but updated for the latest version of Convex.
I've added an endpoint for processing webhook events from resend:
app.post(
"/webhooks/resend/:accountId",
async (c) => {
console.log("Received resend webhook");
const accountId = c.req.param("accountId");
const account = await c.env.runQuery(internal.user.account.fetchAccountInternal, { accountId: accountId as Id<"account"> });
if (!account) {
return c.json({ error: "Account not found" }, 404);
}
const resend = new Resend(components.resend, {
apiKey: account.resendApiKey,
webhookSecret: account.resendWebhookSecret,
onEmailEvent: internal.email.email.handleEmailEvent,
})
const result = await resend.handleResendEventWebhook(c.env, c.req.raw);
console.log("Resend webhook result: ", result);
return result;
}
)
The logged output is:
7/25/2025, 11:59:58 AM [CONVEX H(POST /webhooks/resend/3zweykav7h0650e048nscwhe9pt53m0)] [LOG] 'Received resend webhook'
7/25/2025, 11:59:58 AM [CONVEX H(POST /webhooks/resend/3zweykav7h0650e048nscwhe9pt53m0)] [LOG] 'Resend webhook result: ' Response { bodyUsed: false, headers: Headers {}, ok: true, status: 201, statusText: '', url: '' }
But my handleEmailEvent method is never called. It's just copied from the convex/resend documentation:
export const handleEmailEvent = internalMutation({
args: {
id: vEmailId,
event: vEmailEvent,
},
handler: async (ctx, args) => {
console.log("Got called back!", args.id, args.event);
},
});
Other than using Hono the main difference in how I'm doing things is constructing the Resend instance on the fly, but this is working fine for sending emails, so I assume this is OK?
Any help would be greatly appreciated. Thanks!