Skip to content

Commit 9f012c1

Browse files
committed
fix(imap): add top-level fields to IMAP trigger output
1 parent b85245d commit 9f012c1

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

apps/sim/lib/webhooks/imap-polling-service.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ export interface SimplifiedImapEmail {
5454
}
5555

5656
export interface ImapWebhookPayload {
57+
messageId: string
58+
subject: string
59+
from: string
60+
to: string
61+
cc: string
62+
date: string | null
63+
bodyText: string
64+
bodyHtml: string
65+
mailbox: string
66+
hasAttachments: boolean
67+
attachments: ImapAttachment[]
5768
email: SimplifiedImapEmail
5869
timestamp: string
5970
}
@@ -613,6 +624,17 @@ async function processEmails(
613624
}
614625

615626
const payload: ImapWebhookPayload = {
627+
messageId: simplifiedEmail.messageId,
628+
subject: simplifiedEmail.subject,
629+
from: simplifiedEmail.from,
630+
to: simplifiedEmail.to,
631+
cc: simplifiedEmail.cc,
632+
date: simplifiedEmail.date,
633+
bodyText: simplifiedEmail.bodyText,
634+
bodyHtml: simplifiedEmail.bodyHtml,
635+
mailbox: simplifiedEmail.mailbox,
636+
hasAttachments: simplifiedEmail.hasAttachments,
637+
attachments: simplifiedEmail.attachments,
616638
email: simplifiedEmail,
617639
timestamp: new Date().toISOString(),
618640
}

apps/sim/lib/webhooks/utils.server.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,9 @@ export async function formatWebhookInput(
686686
if (foundWebhook.provider === 'rss') {
687687
if (body && typeof body === 'object' && 'item' in body) {
688688
return {
689+
title: body.title,
690+
link: body.link,
691+
pubDate: body.pubDate,
689692
item: body.item,
690693
feed: body.feed,
691694
timestamp: body.timestamp,
@@ -697,6 +700,17 @@ export async function formatWebhookInput(
697700
if (foundWebhook.provider === 'imap') {
698701
if (body && typeof body === 'object' && 'email' in body) {
699702
return {
703+
messageId: body.messageId,
704+
subject: body.subject,
705+
from: body.from,
706+
to: body.to,
707+
cc: body.cc,
708+
date: body.date,
709+
bodyText: body.bodyText,
710+
bodyHtml: body.bodyHtml,
711+
mailbox: body.mailbox,
712+
hasAttachments: body.hasAttachments,
713+
attachments: body.attachments,
700714
email: body.email,
701715
timestamp: body.timestamp,
702716
}

0 commit comments

Comments
 (0)