Skip to content

Commit 38640fa

Browse files
waleedlatif1claude
andcommitted
fix(hubspot): address review comments - schema mismatch, pagination, trim, descriptions
- Switch marketing event outputs to CRM envelope structure (id, properties, createdAt, updatedAt, archived) matching CRM Objects API - Fix list_lists pagination: add offset param, map offset-based response to paging structure - Add .trim() to contactId/companyId in pre-existing get/update tools - Fix default limit descriptions (100 → 10) in list_contacts/list_companies - Fix operator examples (CONTAINS → CONTAINS_TOKEN) in search_contacts/search_companies - Remove unused params arg in get_users transformResponse Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5654c88 commit 38640fa

File tree

13 files changed

+78
-55
lines changed

13 files changed

+78
-55
lines changed

apps/sim/blocks/blocks/hubspot.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,13 @@ Return ONLY the JSON object with properties - no explanations, no markdown, no e
495495
placeholder: 'Search term (e.g., company name, contact email)',
496496
condition: {
497497
field: 'operation',
498-
value: ['search_contacts', 'search_companies', 'search_deals', 'search_tickets', 'get_lists'],
498+
value: [
499+
'search_contacts',
500+
'search_companies',
501+
'search_deals',
502+
'search_tickets',
503+
'get_lists',
504+
],
499505
},
500506
},
501507
{
@@ -1077,9 +1083,7 @@ Return ONLY the JSON array of property names - no explanations, no markdown, no
10771083
case 'get_quotes':
10781084
return params.quoteId ? 'hubspot_get_quote' : 'hubspot_list_quotes'
10791085
case 'get_appointments':
1080-
return params.appointmentId
1081-
? 'hubspot_get_appointment'
1082-
: 'hubspot_list_appointments'
1086+
return params.appointmentId ? 'hubspot_get_appointment' : 'hubspot_list_appointments'
10831087
case 'create_appointment':
10841088
return 'hubspot_create_appointment'
10851089
case 'update_appointment':
@@ -1089,9 +1093,7 @@ Return ONLY the JSON array of property names - no explanations, no markdown, no
10891093
case 'list_owners':
10901094
return 'hubspot_list_owners'
10911095
case 'get_marketing_events':
1092-
return params.eventId
1093-
? 'hubspot_get_marketing_event'
1094-
: 'hubspot_list_marketing_events'
1096+
return params.eventId ? 'hubspot_get_marketing_event' : 'hubspot_list_marketing_events'
10951097
case 'get_lists':
10961098
return params.listId ? 'hubspot_get_list' : 'hubspot_list_lists'
10971099
case 'create_list':
@@ -1150,12 +1152,7 @@ Return ONLY the JSON array of property names - no explanations, no markdown, no
11501152
cleanParams.properties = properties
11511153
}
11521154

1153-
const searchOps = [
1154-
'search_contacts',
1155-
'search_companies',
1156-
'search_deals',
1157-
'search_tickets',
1158-
]
1155+
const searchOps = ['search_contacts', 'search_companies', 'search_deals', 'search_tickets']
11591156
if (searchProperties && searchOps.includes(operation as string)) {
11601157
cleanParams.properties = searchProperties
11611158
}
@@ -1185,9 +1182,15 @@ Return ONLY the JSON array of property names - no explanations, no markdown, no
11851182
cleanParams.name = listName
11861183
}
11871184

1188-
if (operation === 'get_lists' && rest.limit) {
1189-
cleanParams.count = rest.limit
1190-
delete rest.limit
1185+
if (operation === 'get_lists') {
1186+
if (rest.limit) {
1187+
cleanParams.count = rest.limit
1188+
rest.limit = undefined
1189+
}
1190+
if (rest.after) {
1191+
cleanParams.offset = rest.after
1192+
rest.after = undefined
1193+
}
11911194
}
11921195

11931196
const excludeKeys = [

apps/sim/tools/hubspot/get_company.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const hubspotGetCompanyTool: ToolConfig<HubSpotGetCompanyParams, HubSpotG
5555

5656
request: {
5757
url: (params) => {
58-
const baseUrl = `https://api.hubapi.com/crm/v3/objects/companies/${params.companyId}`
58+
const baseUrl = `https://api.hubapi.com/crm/v3/objects/companies/${params.companyId.trim()}`
5959
const queryParams = new URLSearchParams()
6060

6161
if (params.idProperty) {

apps/sim/tools/hubspot/get_contact.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const hubspotGetContactTool: ToolConfig<HubSpotGetContactParams, HubSpotG
5555

5656
request: {
5757
url: (params) => {
58-
const baseUrl = `https://api.hubapi.com/crm/v3/objects/contacts/${params.contactId}`
58+
const baseUrl = `https://api.hubapi.com/crm/v3/objects/contacts/${params.contactId.trim()}`
5959
const queryParams = new URLSearchParams()
6060

6161
if (params.idProperty) {

apps/sim/tools/hubspot/get_marketing_event.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {
33
HubSpotGetMarketingEventParams,
44
HubSpotGetMarketingEventResponse,
55
} from '@/tools/hubspot/types'
6-
import { MARKETING_EVENT_OUTPUT_PROPERTIES } from '@/tools/hubspot/types'
6+
import { MARKETING_EVENT_OBJECT_OUTPUT } from '@/tools/hubspot/types'
77
import type { ToolConfig } from '@/tools/types'
88

99
const logger = createLogger('HubSpotGetMarketingEvent')
@@ -69,11 +69,7 @@ export const hubspotGetMarketingEventTool: ToolConfig<
6969
},
7070

7171
outputs: {
72-
event: {
73-
type: 'object',
74-
description: 'HubSpot marketing event',
75-
properties: MARKETING_EVENT_OUTPUT_PROPERTIES,
76-
},
72+
event: MARKETING_EVENT_OBJECT_OUTPUT,
7773
eventId: { type: 'string', description: 'The retrieved marketing event ID' },
7874
success: { type: 'boolean', description: 'Operation success status' },
7975
},

apps/sim/tools/hubspot/get_users.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const hubspotGetUsersTool: ToolConfig<HubSpotGetUsersParams, HubSpotGetUs
5656
},
5757
},
5858

59-
transformResponse: async (response: Response, params) => {
59+
transformResponse: async (response: Response) => {
6060
const data = await response.json()
6161

6262
if (!response.ok) {

apps/sim/tools/hubspot/list_companies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const hubspotListCompaniesTool: ToolConfig<
3333
type: 'string',
3434
required: false,
3535
visibility: 'user-or-llm',
36-
description: 'Maximum number of results per page (max 100, default 100)',
36+
description: 'Maximum number of results per page (max 100, default 10)',
3737
},
3838
after: {
3939
type: 'string',

apps/sim/tools/hubspot/list_contacts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const hubspotListContactsTool: ToolConfig<
3030
type: 'string',
3131
required: false,
3232
visibility: 'user-or-llm',
33-
description: 'Maximum number of results per page (max 100, default 100)',
33+
description: 'Maximum number of results per page (max 100, default 10)',
3434
},
3535
after: {
3636
type: 'string',

apps/sim/tools/hubspot/list_lists.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ export const hubspotListListsTool: ToolConfig<HubSpotListListsParams, HubSpotLis
3535
visibility: 'user-or-llm',
3636
description: 'Maximum number of results to return (default 25)',
3737
},
38+
offset: {
39+
type: 'string',
40+
required: false,
41+
visibility: 'user-or-llm',
42+
description: 'Pagination offset for next page (from previous response)',
43+
},
3844
},
3945

4046
request: {
@@ -53,6 +59,7 @@ export const hubspotListListsTool: ToolConfig<HubSpotListListsParams, HubSpotLis
5359
const body: Record<string, unknown> = {}
5460
if (params.query) body.query = params.query
5561
if (params.count) body.count = Number(params.count)
62+
if (params.offset) body.offset = Number(params.offset)
5663
return body
5764
},
5865
},
@@ -68,10 +75,12 @@ export const hubspotListListsTool: ToolConfig<HubSpotListListsParams, HubSpotLis
6875
success: true,
6976
output: {
7077
lists,
71-
paging: data.paging ?? null,
78+
paging:
79+
data.offset != null ? { next: { after: String(data.offset) } } : (data.paging ?? null),
7280
metadata: {
7381
totalReturned: lists.length,
74-
hasMore: !!data.paging?.next || data.hasMore === true,
82+
total: data.total ?? null,
83+
hasMore: data.hasMore === true || !!data.paging?.next,
7584
},
7685
success: true,
7786
},

apps/sim/tools/hubspot/search_companies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const hubspotSearchCompaniesTool: ToolConfig<
3434
required: false,
3535
visibility: 'user-or-llm',
3636
description:
37-
'Array of filter groups as JSON. Each group contains "filters" array with objects having "propertyName", "operator" (e.g., "EQ", "CONTAINS"), and "value"',
37+
'Array of filter groups as JSON. Each group contains "filters" array with objects having "propertyName", "operator" (e.g., "EQ", "CONTAINS_TOKEN", "GT"), and "value"',
3838
},
3939
sorts: {
4040
type: 'array',

apps/sim/tools/hubspot/search_contacts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const hubspotSearchContactsTool: ToolConfig<
3434
required: false,
3535
visibility: 'user-or-llm',
3636
description:
37-
'Array of filter groups as JSON. Each group contains "filters" array with objects having "propertyName", "operator" (e.g., "EQ", "CONTAINS"), and "value"',
37+
'Array of filter groups as JSON. Each group contains "filters" array with objects having "propertyName", "operator" (e.g., "EQ", "CONTAINS_TOKEN", "GT"), and "value"',
3838
},
3939
sorts: {
4040
type: 'array',

0 commit comments

Comments
 (0)