Files
simstudioai--sim/apps/sim/tools/apollo/contact_bulk_create.ts
T
wehub-resource-sync d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

113 lines
3.6 KiB
TypeScript

import type {
ApolloContactBulkCreateParams,
ApolloContactBulkCreateResponse,
} from '@/tools/apollo/types'
import type { ToolConfig } from '@/tools/types'
export const apolloContactBulkCreateTool: ToolConfig<
ApolloContactBulkCreateParams,
ApolloContactBulkCreateResponse
> = {
id: 'apollo_contact_bulk_create',
name: 'Apollo Bulk Create Contacts',
description:
'Create up to 100 contacts at once in your Apollo database. Supports deduplication to prevent creating duplicate contacts. Master key required.',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Apollo API key (master key required)',
},
contacts: {
type: 'array',
required: true,
visibility: 'user-or-llm',
description:
'Array of contacts to create (max 100). Each contact may include first_name, last_name, email, title, organization_name, account_id, owner_id, contact_stage_id, linkedin_url, phone (single string) or phone_numbers (array of {raw_number, position}), contact_emails, typed_custom_fields, and CRM IDs (salesforce_contact_id, hubspot_id, team_id) for cross-system matching',
},
append_label_names: {
type: 'array',
required: false,
visibility: 'user-or-llm',
description: 'Label names to add to all contacts in this request (e.g., ["Hot Lead"])',
},
run_dedupe: {
type: 'boolean',
required: false,
visibility: 'user-only',
description:
'Enable deduplication to prevent creating duplicate contacts. When true, existing contacts are returned without modification',
},
},
request: {
url: 'https://api.apollo.io/api/v1/contacts/bulk_create',
method: 'POST',
headers: (params: ApolloContactBulkCreateParams) => ({
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'X-Api-Key': params.apiKey,
}),
body: (params: ApolloContactBulkCreateParams) => {
const body: Record<string, unknown> = {
contacts: params.contacts.slice(0, 100),
}
if (params.run_dedupe !== undefined) {
body.run_dedupe = params.run_dedupe
}
if (params.append_label_names && params.append_label_names.length > 0) {
body.append_label_names = params.append_label_names
}
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const errorText = await response.text()
throw new Error(`Apollo API error: ${response.status} - ${errorText}`)
}
const data = await response.json()
const createdContacts = data.created_contacts || data.contacts || []
const existingContacts = data.existing_contacts || []
return {
success: true,
output: {
created_contacts: createdContacts,
existing_contacts: existingContacts,
total_submitted: createdContacts.length + existingContacts.length,
created: createdContacts.length,
existing: existingContacts.length,
},
}
},
outputs: {
created_contacts: {
type: 'json',
description: 'Array of newly created contacts',
},
existing_contacts: {
type: 'json',
description: 'Array of existing contacts (when deduplication is enabled)',
},
total_submitted: {
type: 'number',
description: 'Total number of contacts submitted',
},
created: {
type: 'number',
description: 'Number of contacts successfully created',
},
existing: {
type: 'number',
description: 'Number of existing contacts found',
},
},
}