Skip to content

Commit 992d45a

Browse files
waleedlatif1claude
andcommitted
fix(zoominfo): default required outputFields on enrich; parse nested API error object
- ZoomInfo enrich endpoints require outputFields; send a curated default set when omitted so requests don't fail - extractZoomInfoError now reads the GTM REST nested error object ({error:{code,message}}) instead of dropping it to a generic HTTP message Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e4eb5e4 commit 992d45a

3 files changed

Lines changed: 73 additions & 6 deletions

File tree

apps/sim/app/api/tools/zoominfo/shared.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ export async function fetchZoomInfoAccessToken(
171171
export function extractZoomInfoError(body: unknown, status: number): string {
172172
if (body && typeof body === 'object') {
173173
const obj = body as Record<string, unknown>
174+
if (obj.error && typeof obj.error === 'object') {
175+
const eo = obj.error as Record<string, unknown>
176+
const message = typeof eo.message === 'string' ? eo.message : ''
177+
const code = typeof eo.code === 'string' ? eo.code : ''
178+
if (message) return code ? `[${code}] ${message}` : message
179+
}
174180
if (typeof obj.error === 'string' && obj.error.length > 0) {
175181
const desc = typeof obj.error_description === 'string' ? `: ${obj.error_description}` : ''
176182
return `${obj.error}${desc}`

apps/sim/tools/zoominfo/enrich_companies.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,36 @@ import {
1212
ZOOMINFO_PROXY_URL,
1313
} from '@/tools/zoominfo/utils'
1414

15+
/**
16+
* Default output fields used when the caller does not specify any. ZoomInfo's
17+
* CompanyEnrich schema requires `outputFields`, so we send a useful firmographic
18+
* set rather than letting the request fail. All values are valid CompanyEnrich fields.
19+
*/
20+
const DEFAULT_COMPANY_OUTPUT_FIELDS = [
21+
'id',
22+
'name',
23+
'website',
24+
'domainList',
25+
'ticker',
26+
'revenue',
27+
'revenueRange',
28+
'employeeCount',
29+
'employeeRange',
30+
'primaryIndustry',
31+
'industries',
32+
'street',
33+
'city',
34+
'state',
35+
'zipCode',
36+
'country',
37+
'phone',
38+
'foundedYear',
39+
'companyStatus',
40+
'socialMediaUrls',
41+
'logo',
42+
'description',
43+
]
44+
1545
export const zoominfoEnrichCompaniesTool: ToolConfig<
1646
ZoomInfoEnrichCompaniesParams,
1747
ZoomInfoEnrichCompaniesResponse
@@ -47,7 +77,7 @@ export const zoominfoEnrichCompaniesTool: ToolConfig<
4777
required: false,
4878
visibility: 'user-or-llm',
4979
description:
50-
'JSON array or comma-separated list of fields to return (e.g. ["id","name","website","revenue","employeeCount"])',
80+
'JSON array or comma-separated list of fields to return (e.g. ["id","name","website","revenue","employeeCount"]). Defaults to a standard firmographic set if omitted.',
5181
},
5282
},
5383

@@ -67,9 +97,11 @@ export const zoominfoEnrichCompaniesTool: ToolConfig<
6797
throw new Error('matchCompanyInput supports a maximum of 25 entries per request')
6898
}
6999

70-
const attributes: Record<string, unknown> = { matchCompanyInput }
71100
const outputFields = parseCsvOrJson(params.outputFields, 'outputFields')
72-
if (outputFields) attributes.outputFields = outputFields
101+
const attributes: Record<string, unknown> = {
102+
matchCompanyInput,
103+
outputFields: outputFields ?? DEFAULT_COMPANY_OUTPUT_FIELDS,
104+
}
73105

74106
return {
75107
...buildProxyBody(params),

apps/sim/tools/zoominfo/enrich_contacts.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,33 @@ import {
1212
ZOOMINFO_PROXY_URL,
1313
} from '@/tools/zoominfo/utils'
1414

15+
/**
16+
* Default output fields used when the caller does not specify any. ZoomInfo's
17+
* ContactEnrich schema requires `outputFields`, so we send a useful contact set
18+
* rather than letting the request fail. All values are valid ContactEnrich fields.
19+
*/
20+
const DEFAULT_CONTACT_OUTPUT_FIELDS = [
21+
'id',
22+
'firstName',
23+
'lastName',
24+
'email',
25+
'phone',
26+
'mobilePhone',
27+
'jobTitle',
28+
'jobFunction',
29+
'managementLevel',
30+
'city',
31+
'state',
32+
'country',
33+
'contactAccuracyScore',
34+
'validDate',
35+
'lastUpdatedDate',
36+
'companyId',
37+
'companyName',
38+
'companyWebsite',
39+
'companyPhone',
40+
]
41+
1542
export const zoominfoEnrichContactsTool: ToolConfig<
1643
ZoomInfoEnrichContactsParams,
1744
ZoomInfoEnrichContactsResponse
@@ -47,7 +74,7 @@ export const zoominfoEnrichContactsTool: ToolConfig<
4774
required: false,
4875
visibility: 'user-or-llm',
4976
description:
50-
'JSON array or comma-separated list of fields to return (e.g. ["id","firstName","email","phone","jobTitle"])',
77+
'JSON array or comma-separated list of fields to return (e.g. ["id","firstName","email","phone","jobTitle"]). Defaults to a standard contact set if omitted.',
5178
},
5279
requiredFields: {
5380
type: 'string',
@@ -71,9 +98,11 @@ export const zoominfoEnrichContactsTool: ToolConfig<
7198
throw new Error('matchPersonInput supports a maximum of 25 entries per request')
7299
}
73100

74-
const attributes: Record<string, unknown> = { matchPersonInput }
75101
const outputFields = parseCsvOrJson(params.outputFields, 'outputFields')
76-
if (outputFields) attributes.outputFields = outputFields
102+
const attributes: Record<string, unknown> = {
103+
matchPersonInput,
104+
outputFields: outputFields ?? DEFAULT_CONTACT_OUTPUT_FIELDS,
105+
}
77106
const requiredFields = parseCsvOrJson(params.requiredFields, 'requiredFields')
78107
if (requiredFields) attributes.requiredFields = requiredFields
79108

0 commit comments

Comments
 (0)