Skip to content

Commit 3d320e5

Browse files
committed
address greptile comments
1 parent 5449aac commit 3d320e5

File tree

3 files changed

+10
-123
lines changed

3 files changed

+10
-123
lines changed

apps/sim/blocks/blocks/lemlist.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const LemlistBlock: BlockConfig<LemlistResponse> = {
5252
condition: { field: 'operation', value: 'get_activities' },
5353
},
5454
{
55-
id: 'leadId',
55+
id: 'filterLeadId',
5656
title: 'Lead ID',
5757
type: 'short-input',
5858
placeholder: 'Filter by lead ID (optional)',
@@ -175,6 +175,10 @@ export const LemlistBlock: BlockConfig<LemlistResponse> = {
175175
if (params.offset) {
176176
params.offset = Number(params.offset)
177177
}
178+
// Map filterLeadId to leadId for get_activities tool
179+
if (params.filterLeadId) {
180+
params.leadId = params.filterLeadId
181+
}
178182

179183
switch (params.operation) {
180184
case 'get_activities':
@@ -194,7 +198,8 @@ export const LemlistBlock: BlockConfig<LemlistResponse> = {
194198
apiKey: { type: 'string', description: 'Lemlist API key' },
195199
type: { type: 'string', description: 'Activity type filter' },
196200
campaignId: { type: 'string', description: 'Campaign ID filter' },
197-
leadId: { type: 'string', description: 'Lead ID' },
201+
filterLeadId: { type: 'string', description: 'Lead ID filter for activities' },
202+
leadId: { type: 'string', description: 'Lead ID for send email' },
198203
limit: { type: 'number', description: 'Result limit' },
199204
offset: { type: 'number', description: 'Result offset' },
200205
leadIdentifier: { type: 'string', description: 'Lead email address or ID' },

apps/sim/triggers/lemlist/utils.ts

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -266,81 +266,3 @@ export function buildAllOutputs(): Record<string, TriggerOutput> {
266266
},
267267
}
268268
}
269-
270-
/**
271-
* Check if a webhook event matches the expected trigger type
272-
*/
273-
export function isLemlistEventMatch(triggerId: string, eventType: string): boolean {
274-
const eventMappings: Record<string, string[]> = {
275-
lemlist_email_replied: ['emailsReplied', 'emailReplied'],
276-
lemlist_linkedin_replied: ['linkedinReplied'],
277-
lemlist_interested: [
278-
'interested',
279-
'emailsInterested',
280-
'linkedinInterested',
281-
'manualInterested',
282-
'aircallInterested',
283-
'apiInterested',
284-
],
285-
lemlist_not_interested: [
286-
'notInterested',
287-
'emailsNotInterested',
288-
'linkedinNotInterested',
289-
'manualNotInterested',
290-
'aircallNotInterested',
291-
'apiNotInterested',
292-
],
293-
lemlist_email_opened: ['emailsOpened', 'emailOpened'],
294-
lemlist_email_clicked: ['emailsClicked', 'emailClicked'],
295-
lemlist_email_bounced: ['emailsBounced', 'emailBounced'],
296-
lemlist_email_sent: ['emailsSent', 'emailSent'],
297-
// Generic webhook accepts all events
298-
lemlist_webhook: ['*'],
299-
}
300-
301-
const expectedEvents = eventMappings[triggerId]
302-
if (!expectedEvents) {
303-
return false
304-
}
305-
306-
// Generic webhook accepts all events
307-
if (expectedEvents.includes('*')) {
308-
return true
309-
}
310-
311-
return expectedEvents.includes(eventType)
312-
}
313-
314-
/**
315-
* Extract and normalize data from Lemlist webhook payload
316-
*/
317-
export function extractLemlistData(body: Record<string, unknown>) {
318-
return {
319-
type: body.type ?? body.eventType ?? '',
320-
_id: body._id ?? body.activityId ?? '',
321-
leadId: body.leadId ?? '',
322-
campaignId: body.campaignId ?? '',
323-
campaignName: body.campaignName ?? '',
324-
sequenceId: body.sequenceId ?? '',
325-
stepId: body.stepId ?? '',
326-
createdAt: body.createdAt ?? body.timestamp ?? '',
327-
lead: body.lead ?? {
328-
_id: body.leadId ?? '',
329-
email: body.email ?? body.leadEmail ?? '',
330-
firstName: body.firstName ?? body.leadFirstName ?? '',
331-
lastName: body.lastName ?? body.leadLastName ?? '',
332-
companyName: body.companyName ?? '',
333-
phone: body.phone ?? '',
334-
linkedinUrl: body.linkedinUrl ?? '',
335-
picture: body.picture ?? '',
336-
icebreaker: body.icebreaker ?? '',
337-
timezone: body.timezone ?? '',
338-
isUnsubscribed: body.isUnsubscribed ?? false,
339-
},
340-
messageId: body.messageId ?? '',
341-
subject: body.subject ?? '',
342-
text: body.text ?? body.message ?? '',
343-
html: body.html ?? '',
344-
sentAt: body.sentAt ?? '',
345-
}
346-
}

apps/sim/triggers/lemlist/webhook.ts

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { LemlistIcon } from '@/components/icons'
22
import { buildTriggerSubBlocks } from '@/triggers'
33
import {
44
buildAllOutputs,
5+
buildLemlistExtraFields,
56
lemlistSetupInstructions,
67
lemlistTriggerOptions,
78
} from '@/triggers/lemlist/utils'
@@ -22,49 +23,8 @@ export const lemlistWebhookTrigger: TriggerConfig = {
2223
subBlocks: buildTriggerSubBlocks({
2324
triggerId: 'lemlist_webhook',
2425
triggerOptions: lemlistTriggerOptions,
25-
setupInstructions: lemlistSetupInstructions('All Events (omit type field)'),
26-
extraFields: [
27-
{
28-
id: 'eventTypes',
29-
title: 'Event Types to Listen For',
30-
type: 'dropdown',
31-
multiSelect: true,
32-
options: [
33-
// Email Events
34-
{ label: 'Email Sent', id: 'emailsSent' },
35-
{ label: 'Email Opened', id: 'emailsOpened' },
36-
{ label: 'Email Clicked', id: 'emailsClicked' },
37-
{ label: 'Email Replied', id: 'emailsReplied' },
38-
{ label: 'Email Bounced', id: 'emailsBounced' },
39-
{ label: 'Email Unsubscribed', id: 'emailsUnsubscribed' },
40-
// LinkedIn Events
41-
{ label: 'LinkedIn Replied', id: 'linkedinReplied' },
42-
{ label: 'LinkedIn Invite Accepted', id: 'linkedinInviteAccepted' },
43-
{ label: 'LinkedIn Sent', id: 'linkedinSent' },
44-
// Lead Status Events
45-
{ label: 'Interested', id: 'interested' },
46-
{ label: 'Not Interested', id: 'notInterested' },
47-
{ label: 'Contacted', id: 'contacted' },
48-
{ label: 'Paused', id: 'paused' },
49-
// System Events
50-
{ label: 'Campaign Complete', id: 'campaignComplete' },
51-
],
52-
placeholder: 'Leave empty to receive all events',
53-
description:
54-
'Select specific events to filter. Leave empty to receive all events from Lemlist.',
55-
mode: 'trigger',
56-
condition: { field: 'selectedTriggerId', value: 'lemlist_webhook' },
57-
},
58-
{
59-
id: 'campaignId',
60-
title: 'Campaign ID (Optional)',
61-
type: 'short-input',
62-
placeholder: 'cam_xxxxx (leave empty for all campaigns)',
63-
description: 'Optionally scope the webhook to a specific campaign',
64-
mode: 'trigger',
65-
condition: { field: 'selectedTriggerId', value: 'lemlist_webhook' },
66-
},
67-
],
26+
setupInstructions: lemlistSetupInstructions('All Events (no type filter)'),
27+
extraFields: buildLemlistExtraFields('lemlist_webhook'),
6828
}),
6929

7030
outputs: buildAllOutputs(),

0 commit comments

Comments
 (0)