Skip to content

Commit a1b4c52

Browse files
committed
fix(integrations): keep wealthbox read outputs and id requirements compatible and send email bison without-tags only when on
1 parent 88757e6 commit a1b4c52

11 files changed

Lines changed: 120 additions & 92 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +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\) |
60+
| ↳ `notes` | array | Notes in the returned page when no ID is given \(list request\) |
6161
| ↳ `metadata` | object | Operation metadata |
6262
| ↳ `itemId` | string | ID of the note |
6363
| ↳ `noteId` | string | ID of the note |
64-
| ↳ `totalItems` | number | Number of items returned by a list request |
64+
| ↳ `totalItems` | number | Number of items in the returned page \(list requests only\) |
6565
| ↳ `itemType` | string | Type of item \(note\) |
6666

6767
</ReferenceDetails>
@@ -114,11 +114,11 @@ Read content from a Wealthbox contact
114114
| `output` | object | Contact data and metadata |
115115
| ↳ `content` | string | Formatted contact information |
116116
| ↳ `contact` | object | Raw contact data from Wealthbox |
117-
| ↳ `contacts` | array | Contacts returned when no ID is given \(list request\) |
117+
| ↳ `contacts` | array | Contacts in the returned page when no ID is given \(list request\) |
118118
| ↳ `metadata` | object | Operation metadata |
119119
| ↳ `itemId` | string | ID of the contact |
120120
| ↳ `contactId` | string | ID of the contact |
121-
| ↳ `totalItems` | number | Number of items returned by a list request |
121+
| ↳ `totalItems` | number | Number of items in the returned page \(list requests only\) |
122122
| ↳ `itemType` | string | Type of item \(contact\) |
123123

124124
</ReferenceDetails>
@@ -173,11 +173,11 @@ Read content from a Wealthbox task
173173
| `output` | object | Task data and metadata |
174174
| ↳ `content` | string | Formatted task information |
175175
| ↳ `task` | object | Raw task data from Wealthbox |
176-
| ↳ `tasks` | array | Tasks returned when no ID is given \(list request\) |
176+
| ↳ `tasks` | array | Tasks in the returned page when no ID is given \(list request\) |
177177
| ↳ `metadata` | object | Operation metadata |
178178
| ↳ `itemId` | string | ID of the task |
179179
| ↳ `taskId` | string | ID of the task |
180-
| ↳ `totalItems` | number | Number of items returned by a list request |
180+
| ↳ `totalItems` | number | Number of items in the returned page \(list requests only\) |
181181
| ↳ `itemType` | string | Type of item \(task\) |
182182

183183
</ReferenceDetails>

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

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,29 +59,86 @@ describe('Wealthbox Write Task', () => {
5959
})
6060

6161
describe('Wealthbox Read Note without a note ID', () => {
62-
it('returns the listed notes from the status_updates array', async () => {
62+
it('returns the listed notes and keeps the raw list body under note', async () => {
6363
const transform = wealthboxReadNoteTool.transformResponse
6464
if (!transform) throw new Error('Read note tool has no transformResponse')
6565

6666
const notes = [{ id: 1, content: 'Spoke with the client' }]
6767
const result = await transform(Response.json({ status_updates: notes }))
6868

69-
expect(result.output).toMatchObject({ notes, metadata: { totalItems: 1 } })
69+
expect(result.output).toMatchObject({
70+
notes,
71+
note: { status_updates: notes },
72+
metadata: { totalItems: 1 },
73+
})
7074
})
7175
})
7276

73-
describe('Wealthbox canvas reads without an ID', () => {
74-
it('lists tasks when Read Task has no task ID', () => {
75-
const params = mapParams({ operation: 'read_task', oauthCredential: 'cred', taskId: '' })
76-
const url = wealthboxReadTaskTool.request.url as (p: Record<string, unknown>) => string
77+
function readUrl(
78+
tool: typeof wealthboxReadTaskTool,
79+
operation: 'read_task' | 'read_contact',
80+
params: Record<string, unknown>
81+
) {
82+
const url = tool.request.url
83+
if (typeof url !== 'function') throw new Error('Read tool has no URL builder')
84+
const id = (value: unknown) => (typeof value === 'string' ? value : undefined)
85+
return url({
86+
accessToken: 'token',
87+
operation,
88+
taskId: id(params.taskId),
89+
contactId: id(params.contactId),
90+
})
91+
}
92+
93+
describe('Wealthbox reads without an ID', () => {
94+
it('still requires a task ID on the canvas', () => {
95+
expect(() =>
96+
mapParams({ operation: 'read_task', oauthCredential: 'cred', taskId: '' })
97+
).toThrow('Task ID is required')
98+
})
99+
100+
it('still requires a contact ID on the canvas', () => {
101+
expect(() =>
102+
mapParams({ operation: 'read_contact', oauthCredential: 'cred', contactId: '' })
103+
).toThrow('Contact ID is required')
104+
})
105+
106+
it('lists tasks on an agent call with no task ID', () => {
107+
const params = mapParams({ oauthCredential: 'cred' }, { operation: 'read_task' })
108+
109+
expect(readUrl(wealthboxReadTaskTool, 'read_task', params)).toBe(
110+
'https://api.crmworkspace.com/v1/tasks'
111+
)
112+
})
113+
114+
it('lists contacts on an agent call with no contact ID', () => {
115+
const params = mapParams({ oauthCredential: 'cred' }, { operation: 'read_contact' })
77116

78-
expect(url(params)).toBe('https://api.crmworkspace.com/v1/tasks')
117+
expect(readUrl(wealthboxReadContactTool, 'read_contact', params)).toBe(
118+
'https://api.crmworkspace.com/v1/contacts'
119+
)
79120
})
121+
})
80122

81-
it('lists contacts when Read Contact has no contact ID', () => {
82-
const params = mapParams({ operation: 'read_contact', oauthCredential: 'cred', contactId: '' })
83-
const url = wealthboxReadContactTool.request.url as (p: Record<string, unknown>) => string
123+
describe('Wealthbox Write Task with a stale Read Task ID', () => {
124+
it('creates the task instead of posting to the stale task path', () => {
125+
const params = mapParams({
126+
operation: 'write_task',
127+
oauthCredential: 'cred',
128+
title: 'Call client',
129+
dueDate: '2026-01-05 11:00 AM -0500',
130+
contactId: '42',
131+
taskId: '999',
132+
})
133+
const url = wealthboxWriteTaskTool.request.url
134+
if (typeof url !== 'function') throw new Error('Write task tool has no URL builder')
84135

85-
expect(url(params)).toBe('https://api.crmworkspace.com/v1/contacts')
136+
expect(
137+
url({
138+
accessToken: 'token',
139+
operation: 'write_task',
140+
taskId: typeof params.taskId === 'string' ? params.taskId : undefined,
141+
})
142+
).toBe('https://api.crmworkspace.com/v1/tasks')
86143
})
87144
})

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ export const WealthboxBlock: BlockConfig = {
2727
{ text: 'Write note', field: 'content', core: true },
2828
{ text: 'on contact', field: CONTACT_FIELD },
2929
],
30-
read_contact: ['Read contacts', { text: ', or contact', field: CONTACT_FIELD }],
30+
read_contact: [{ text: 'Read contact', field: CONTACT_FIELD, core: true }],
3131
write_contact: [
3232
{ text: 'Create contact', field: 'firstName', core: true },
3333
{ text: ', with email', field: 'emailAddress' },
3434
],
35-
read_task: ['Read tasks', { text: ', or task', field: 'taskId' }],
35+
read_task: [{ text: 'Read task', field: 'taskId', core: true }],
3636
write_task: [
3737
{ text: 'Write task', field: 'title', core: true },
3838
{ text: 'for contact', field: CONTACT_FIELD },
@@ -109,7 +109,7 @@ export const WealthboxBlock: BlockConfig = {
109109
id: 'taskId',
110110
title: 'Task ID',
111111
type: 'short-input',
112-
placeholder: 'Enter Task ID (optional)',
112+
placeholder: 'Enter Task ID',
113113
condition: { field: 'operation', value: ['read_task'] },
114114
},
115115
{
@@ -228,13 +228,19 @@ Return ONLY the date/time string - no explanations, no quotes, no extra text.`,
228228
}
229229
}
230230
if (operation === 'read_contact') {
231+
if (!effectiveContactId && !isToolCall(context)) {
232+
throw new Error('Contact ID is required for contact operations')
233+
}
231234
return {
232235
...baseParams,
233236
contactId: effectiveContactId,
234237
}
235238
}
236239
if (operation === 'read_task') {
237-
if (!taskId?.trim()) return baseParams
240+
if (!taskId?.trim()) {
241+
if (isToolCall(context)) return baseParams
242+
throw new Error('Task ID is required for task operations')
243+
}
238244
return {
239245
...baseParams,
240246
taskId: taskId.trim(),
@@ -243,7 +249,11 @@ Return ONLY the date/time string - no explanations, no quotes, no extra text.`,
243249
if (operation === 'write_task') {
244250
const content = typeof params.content === 'string' ? params.content.trim() : ''
245251
const description = toolCallArg(context, params.description) || content || undefined
246-
const taskParams = description ? { ...baseParams, description } : baseParams
252+
const taskParams = {
253+
...baseParams,
254+
...(description ? { description } : {}),
255+
taskId: toolCallArg(context, taskId),
256+
}
247257
if (!contactId?.trim()) {
248258
if (isToolCall(context)) return taskParams
249259
throw new Error('Contact ID is required for this operation')

‎apps/sim/tools/emailbison/emailbison.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ describe('Email Bison list filters use Laravel query syntax', () => {
2323

2424
expect(params.get('filters[lead_campaign_status]')).toBe('replied')
2525
expect(params.getAll('filters[tag_ids][]')).toEqual(['11', '12'])
26-
expect(params.get('filters[without_tags]')).toBe('0')
26+
expect(params.has('filters[without_tags]')).toBe(false)
27+
})
28+
29+
it('sends the without-tags filter as 1 only when it is on', () => {
30+
expect(query(listLeadsTool, { withoutTags: true }).get('filters[without_tags]')).toBe('1')
2731
})
2832

2933
it('sends every List Replies tag ID and the read flag as 1', () => {

‎apps/sim/tools/emailbison/list_leads.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const listLeadsTool: ToolConfig<EmailBisonListLeadsParams, EmailBisonList
6464
'filters[lead_campaign_status]': params.campaignStatus,
6565
'filters[tag_ids]': params.tagIds,
6666
'filters[excluded_tag_ids]': params.excludedTagIds,
67-
'filters[without_tags]': params.withoutTags,
67+
'filters[without_tags]': params.withoutTags === true ? true : undefined,
6868
},
6969
params.apiBaseUrl
7070
),

‎apps/sim/tools/generated/tool-outputs.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎apps/sim/tools/lemlist/lemlist.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ describe('Lemlist Send Email recipient', () => {
6262
message: '<p>Hi</p>',
6363
})
6464

65-
expect(result.contactId).toBeUndefined()
66-
expect(result.leadId).toBe('lea_1')
65+
expect(result).toEqual(expect.objectContaining({ contactId: undefined, leadId: 'lea_1' }))
6766
})
6867

6968
it('rejects a send with neither a contact nor a lead ID', () => {

‎apps/sim/tools/wealthbox/read_contact.ts‎

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,7 @@ export const wealthboxReadContactTool: ToolConfig<WealthboxReadParams, Wealthbox
5050
transformResponse: async (response: Response) => {
5151
const data = await response.json()
5252

53-
if (Array.isArray(data?.contacts)) {
54-
const contacts = data.contacts
55-
return {
56-
success: true,
57-
output: {
58-
content: `Found ${contacts.length} contacts`,
59-
contacts,
60-
metadata: {
61-
itemType: 'contact' as const,
62-
totalItems: contacts.length,
63-
},
64-
},
65-
}
66-
}
53+
const listed: unknown[] | undefined = Array.isArray(data?.contacts) ? data.contacts : undefined
6754

6855
// Format contact information into readable content
6956
const contact = data
@@ -96,10 +83,12 @@ export const wealthboxReadContactTool: ToolConfig<WealthboxReadParams, Wealthbox
9683
output: {
9784
content,
9885
contact,
86+
...(listed ? { contacts: listed } : {}),
9987
metadata: {
10088
itemId: contact.id?.toString() ?? null,
10189
contactId: contact.id?.toString() ?? null,
10290
itemType: 'contact' as const,
91+
...(listed ? { totalItems: listed.length } : {}),
10392
},
10493
},
10594
}
@@ -112,14 +101,10 @@ export const wealthboxReadContactTool: ToolConfig<WealthboxReadParams, Wealthbox
112101
description: 'Contact data and metadata',
113102
properties: {
114103
content: { type: 'string', description: 'Formatted contact information' },
115-
contact: {
116-
type: 'object',
117-
description: 'Raw contact data from Wealthbox',
118-
optional: true,
119-
},
104+
contact: { type: 'object', description: 'Raw contact data from Wealthbox' },
120105
contacts: {
121106
type: 'array',
122-
description: 'Contacts returned when no ID is given (list request)',
107+
description: 'Contacts in the returned page when no ID is given (list request)',
123108
optional: true,
124109
},
125110
metadata: {
@@ -130,7 +115,7 @@ export const wealthboxReadContactTool: ToolConfig<WealthboxReadParams, Wealthbox
130115
contactId: { type: 'string', description: 'ID of the contact', optional: true },
131116
totalItems: {
132117
type: 'number',
133-
description: 'Number of items returned by a list request',
118+
description: 'Number of items in the returned page (list requests only)',
134119
optional: true,
135120
},
136121
itemType: { type: 'string', description: 'Type of item (contact)' },

‎apps/sim/tools/wealthbox/read_note.ts‎

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,9 @@ export const wealthboxReadNoteTool: ToolConfig<WealthboxReadParams, WealthboxRea
5050
transformResponse: async (response: Response) => {
5151
const data = await response.json()
5252

53-
if (Array.isArray(data?.status_updates)) {
54-
const notes = data.status_updates
55-
return {
56-
success: true,
57-
output: {
58-
content: `Found ${notes.length} notes`,
59-
notes,
60-
metadata: {
61-
itemType: 'note' as const,
62-
totalItems: notes.length,
63-
},
64-
},
65-
}
66-
}
53+
const listed: unknown[] | undefined = Array.isArray(data?.status_updates)
54+
? data.status_updates
55+
: undefined
6756

6857
// Format note information into readable content
6958
const note = data
@@ -100,10 +89,12 @@ export const wealthboxReadNoteTool: ToolConfig<WealthboxReadParams, WealthboxRea
10089
output: {
10190
content,
10291
note,
92+
...(listed ? { notes: listed } : {}),
10393
metadata: {
10494
itemId: note.id?.toString() ?? null,
10595
noteId: note.id?.toString() ?? null,
10696
itemType: 'note' as const,
97+
...(listed ? { totalItems: listed.length } : {}),
10798
},
10899
},
109100
}
@@ -116,14 +107,10 @@ export const wealthboxReadNoteTool: ToolConfig<WealthboxReadParams, WealthboxRea
116107
description: 'Note data and metadata',
117108
properties: {
118109
content: { type: 'string', description: 'Formatted note information' },
119-
note: {
120-
type: 'object',
121-
description: 'Raw note data from Wealthbox',
122-
optional: true,
123-
},
110+
note: { type: 'object', description: 'Raw note data from Wealthbox' },
124111
notes: {
125112
type: 'array',
126-
description: 'Notes returned when no ID is given (list request)',
113+
description: 'Notes in the returned page when no ID is given (list request)',
127114
optional: true,
128115
},
129116
metadata: {
@@ -134,7 +121,7 @@ export const wealthboxReadNoteTool: ToolConfig<WealthboxReadParams, WealthboxRea
134121
noteId: { type: 'string', description: 'ID of the note', optional: true },
135122
totalItems: {
136123
type: 'number',
137-
description: 'Number of items returned by a list request',
124+
description: 'Number of items in the returned page (list requests only)',
138125
optional: true,
139126
},
140127
itemType: { type: 'string', description: 'Type of item (note)' },

0 commit comments

Comments
 (0)