Skip to content

Commit 08551b3

Browse files
committed
fix(integrations): validate wealthbox, lemlist, emailbison, instantly, attio
1 parent f345300 commit 08551b3

61 files changed

Lines changed: 469 additions & 96 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/docs/content/docs/integrations/lemlist.mdx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Retrieves campaign activities and steps performed, including email opens, clicks
3131

3232
| Parameter | Type | Required | Description |
3333
| --------- | ---- | -------- | ----------- |
34-
| `type` | string | No | Filter by activity type \(e.g., emailOpened, emailClicked, emailReplied, paused\) |
34+
| `type` | string | No | Filter by activity type \(e.g., emailsOpened, emailsClicked, emailsReplied, emailsBounced, paused\) |
3535
| `campaignId` | string | No | Filter by campaign ID \(e.g., "cam_abc123def456"\) |
3636
| `leadId` | string | No | Filter by lead ID \(e.g., "lea_abc123def456"\) |
3737
| `isFirst` | boolean | No | Filter for first activity only |
@@ -97,8 +97,8 @@ Sends an email to a contact through the Lemlist inbox.
9797
| `sendUserId` | string | Yes | Identifier for the user sending the message \(e.g., "usr_abc123def456"\) |
9898
| `sendUserEmail` | string | Yes | Email address of the sender \(e.g., "sales@company.com"\) |
9999
| `sendUserMailboxId` | string | Yes | Mailbox identifier for the sender \(e.g., "mbx_abc123def456"\) |
100-
| `contactId` | string | Yes | Recipient contact identifier \(e.g., "con_abc123def456"\) |
101-
| `leadId` | string | Yes | Associated lead identifier \(e.g., "lea_abc123def456"\) |
100+
| `contactId` | string | No | Recipient contact identifier \(e.g., "ctc_abc123def456"\). Provide this or the lead ID. |
101+
| `leadId` | string | No | Associated lead identifier \(e.g., "lea_abc123def456"\). Provide this or the contact ID. |
102102
| `subject` | string | Yes | Email subject line |
103103
| `message` | string | Yes | Email message body in HTML format |
104104
| `cc` | json | No | Array of CC email addresses |

‎apps/docs/content/docs/integrations/wealthbox.mdx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ Read content from a Wealthbox note
5757
| `output` | object | Note data and metadata |
5858
| ↳ `content` | string | Formatted note information |
5959
| ↳ `note` | object | Raw note data from Wealthbox |
60+
| ↳ `notes` | array | Notes returned when no ID is given \(list request\) |
6061
| ↳ `metadata` | object | Operation metadata |
6162
| ↳ `itemId` | string | ID of the note |
6263
| ↳ `noteId` | string | ID of the note |
64+
| ↳ `totalItems` | number | Number of items returned by a list request |
6365
| ↳ `itemType` | string | Type of item \(note\) |
6466

6567
</ReferenceDetails>
@@ -112,9 +114,11 @@ Read content from a Wealthbox contact
112114
| `output` | object | Contact data and metadata |
113115
| ↳ `content` | string | Formatted contact information |
114116
| ↳ `contact` | object | Raw contact data from Wealthbox |
117+
| ↳ `contacts` | array | Contacts returned when no ID is given \(list request\) |
115118
| ↳ `metadata` | object | Operation metadata |
116119
| ↳ `itemId` | string | ID of the contact |
117120
| ↳ `contactId` | string | ID of the contact |
121+
| ↳ `totalItems` | number | Number of items returned by a list request |
118122
| ↳ `itemType` | string | Type of item \(contact\) |
119123

120124
</ReferenceDetails>
@@ -169,9 +173,11 @@ Read content from a Wealthbox task
169173
| `output` | object | Task data and metadata |
170174
| ↳ `content` | string | Formatted task information |
171175
| ↳ `task` | object | Raw task data from Wealthbox |
176+
| ↳ `tasks` | array | Tasks returned when no ID is given \(list request\) |
172177
| ↳ `metadata` | object | Operation metadata |
173178
| ↳ `itemId` | string | ID of the task |
174179
| ↳ `taskId` | string | ID of the task |
180+
| ↳ `totalItems` | number | Number of items returned by a list request |
175181
| ↳ `itemType` | string | Type of item \(task\) |
176182

177183
</ReferenceDetails>

‎apps/sim/blocks/blocks/lemlist.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,14 @@ export const LemlistBlock: BlockConfig = {
153153
id: 'contactId',
154154
title: 'Contact ID',
155155
type: 'short-input',
156-
placeholder: 'Recipient contact ID',
157-
required: { field: 'operation', value: 'send_email' },
156+
placeholder: 'Recipient contact ID (or provide the lead ID)',
158157
condition: { field: 'operation', value: 'send_email' },
159158
},
160159
{
161160
id: 'leadId',
162161
title: 'Lead ID',
163162
type: 'short-input',
164-
placeholder: 'Associated lead ID',
165-
required: { field: 'operation', value: 'send_email' },
163+
placeholder: 'Associated lead ID (or provide the contact ID)',
166164
condition: { field: 'operation', value: 'send_email' },
167165
},
168166
{
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { describe, expect, it } from 'vitest'
2+
import { WealthboxBlock } from '@/blocks/blocks/wealthbox'
3+
import { wealthboxReadNoteTool } from '@/tools/wealthbox/read_note'
4+
import { wealthboxWriteTaskTool } from '@/tools/wealthbox/write_task'
5+
6+
function mapParams(params: Record<string, unknown>, context?: { operation: string }) {
7+
const mapper = WealthboxBlock.tools.config?.params
8+
if (!mapper) throw new Error('Wealthbox block has no params mapper')
9+
return { ...params, ...mapper(params, context) }
10+
}
11+
12+
function taskBody(params: Record<string, unknown>) {
13+
const body = wealthboxWriteTaskTool.request.body
14+
if (!body) throw new Error('Write task tool has no request body')
15+
return body(params as Parameters<typeof body>[0])
16+
}
17+
18+
describe('Wealthbox Write Task', () => {
19+
it('sends the block Content field as the task description', () => {
20+
const params = mapParams({
21+
operation: 'write_task',
22+
oauthCredential: 'cred',
23+
title: 'Call client',
24+
dueDate: '2026-01-05 11:00 AM -0500',
25+
content: 'Review the portfolio',
26+
contactId: '42',
27+
})
28+
29+
expect(taskBody(params)).toMatchObject({
30+
name: 'Call client',
31+
description: 'Review the portfolio',
32+
linked_to: [{ id: 42, type: 'Contact' }],
33+
})
34+
})
35+
36+
it('keeps the model description on an agent tool call', () => {
37+
const params = mapParams(
38+
{
39+
oauthCredential: 'cred',
40+
title: 'Call client',
41+
dueDate: '2026-01-05 11:00 AM -0500',
42+
description: 'From the model',
43+
},
44+
{ operation: 'write_task' }
45+
)
46+
47+
expect(taskBody(params)).toMatchObject({ description: 'From the model' })
48+
})
49+
})
50+
51+
describe('Wealthbox Read Note without a note ID', () => {
52+
it('returns the listed notes from the status_updates array', async () => {
53+
const transform = wealthboxReadNoteTool.transformResponse
54+
if (!transform) throw new Error('Read note tool has no transformResponse')
55+
56+
const notes = [{ id: 1, content: 'Spoke with the client' }]
57+
const result = await transform(Response.json({ status_updates: notes }))
58+
59+
expect(result.output).toMatchObject({ notes, metadata: { totalItems: 1 } })
60+
})
61+
})

‎apps/sim/blocks/blocks/wealthbox.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { WealthboxIcon } from '@/components/icons'
22
import { getScopesForService } from '@/lib/oauth/utils'
33
import type { BlockConfig, BlockMeta } from '@/blocks/types'
44
import { AuthMode, IntegrationType } from '@/blocks/types'
5-
import { isToolCall, mapperOperation } from '@/blocks/utils'
5+
import { isToolCall, mapperOperation, toolCallArg } from '@/blocks/utils'
66

77
const CONTACT_FIELD = ['contactId', 'manualContactId'] as const
88

@@ -246,13 +246,16 @@ Return ONLY the date/time string - no explanations, no quotes, no extra text.`,
246246
taskId: taskId.trim(),
247247
}
248248
}
249-
if (operation === 'write_task' || operation === 'write_note') {
249+
if (operation === 'write_task') {
250+
const content = typeof params.content === 'string' ? params.content.trim() : ''
251+
const description = toolCallArg(context, params.description) || content || undefined
252+
const taskParams = description ? { ...baseParams, description } : baseParams
250253
if (!contactId?.trim()) {
251-
if (isToolCall(context)) return baseParams
254+
if (isToolCall(context)) return taskParams
252255
throw new Error('Contact ID is required for this operation')
253256
}
254257
return {
255-
...baseParams,
258+
...taskParams,
256259
contactId: contactId.trim(),
257260
}
258261
}

‎apps/sim/lib/webhooks/providers/lemlist.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export const lemlistHandler: WebhookProviderHandler = {
5555
webhookId: webhook.id,
5656
})
5757

58-
const lemlistApiUrl = 'https://api.lemlist.com/api/hooks'
58+
const lemlistApiUrl = new URL('https://api.lemlist.com/api/hooks')
59+
if (campaignId) lemlistApiUrl.searchParams.set('campaignId', String(campaignId))
5960

6061
const requestBody: Record<string, unknown> = {
6162
targetUrl: notificationUrl,
@@ -69,7 +70,7 @@ export const lemlistHandler: WebhookProviderHandler = {
6970
requestBody.campaignId = campaignId
7071
}
7172

72-
const lemlistResponse = await outboundFetch(lemlistApiUrl, {
73+
const lemlistResponse = await outboundFetch(lemlistApiUrl.toString(), {
7374
method: 'POST',
7475
headers: {
7576
Authorization: `Basic ${authString}`,

‎apps/sim/tools/attio/assert_record.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import type { ToolConfig } from '@/tools/types'
3+
import { safeUrlPathSegment } from '@/tools/url-path'
34
import type { AttioAssertRecordParams, AttioAssertRecordResponse } from './types'
45
import { RECORD_OUTPUT_PROPERTIES } from './types'
56

@@ -49,7 +50,7 @@ export const attioAssertRecordTool: ToolConfig<AttioAssertRecordParams, AttioAss
4950

5051
request: {
5152
url: (params) =>
52-
`https://api.attio.com/v2/objects/${params.objectType.trim()}/records?matching_attribute=${params.matchingAttribute.trim()}`,
53+
`https://api.attio.com/v2/objects/${safeUrlPathSegment(params.objectType, 'objectType')}/records?matching_attribute=${encodeURIComponent(params.matchingAttribute.trim())}`,
5354
method: 'PUT',
5455
headers: (params) => ({
5556
Authorization: `Bearer ${params.accessToken}`,

‎apps/sim/tools/attio/create_attribute.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import type { ToolConfig } from '@/tools/types'
3+
import { safeUrlPathSegment } from '@/tools/url-path'
34
import type { AttioCreateAttributeParams, AttioCreateAttributeResponse } from './types'
45
import { ATTRIBUTE_OUTPUT_PROPERTIES } from './types'
56

@@ -92,7 +93,7 @@ export const attioCreateAttributeTool: ToolConfig<
9293

9394
request: {
9495
url: (params) =>
95-
`https://api.attio.com/v2/${params.target.trim()}/${params.identifier.trim()}/attributes`,
96+
`https://api.attio.com/v2/${safeUrlPathSegment(params.target, 'target')}/${safeUrlPathSegment(params.identifier, 'identifier')}/attributes`,
9697
method: 'POST',
9798
headers: (params) => ({
9899
Authorization: `Bearer ${params.accessToken}`,

‎apps/sim/tools/attio/create_list_entry.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import type { ToolConfig } from '@/tools/types'
3+
import { safeUrlPathSegment } from '@/tools/url-path'
34
import type { AttioCreateListEntryParams, AttioCreateListEntryResponse } from './types'
45
import { LIST_ENTRY_OUTPUT_PROPERTIES } from './types'
56

@@ -53,7 +54,8 @@ export const attioCreateListEntryTool: ToolConfig<
5354
},
5455

5556
request: {
56-
url: (params) => `https://api.attio.com/v2/lists/${params.list.trim()}/entries`,
57+
url: (params) =>
58+
`https://api.attio.com/v2/lists/${safeUrlPathSegment(params.list, 'list')}/entries`,
5759
method: 'POST',
5860
headers: (params) => ({
5961
Authorization: `Bearer ${params.accessToken}`,

‎apps/sim/tools/attio/create_record.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import type { ToolConfig } from '@/tools/types'
3+
import { safeUrlPathSegment } from '@/tools/url-path'
34
import type { AttioCreateRecordParams, AttioCreateRecordResponse } from './types'
45
import { RECORD_OBJECT_OUTPUT } from './types'
56

@@ -39,7 +40,8 @@ export const attioCreateRecordTool: ToolConfig<AttioCreateRecordParams, AttioCre
3940
},
4041

4142
request: {
42-
url: (params) => `https://api.attio.com/v2/objects/${params.objectType.trim()}/records`,
43+
url: (params) =>
44+
`https://api.attio.com/v2/objects/${safeUrlPathSegment(params.objectType, 'objectType')}/records`,
4345
method: 'POST',
4446
headers: (params) => ({
4547
Authorization: `Bearer ${params.accessToken}`,

0 commit comments

Comments
 (0)