d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
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
138 lines
3.6 KiB
TypeScript
138 lines
3.6 KiB
TypeScript
import type { InstantlyLeadResponse, InstantlyPatchLeadParams } from '@/tools/instantly/types'
|
|
import {
|
|
compactBody,
|
|
instantlyBaseParamFields,
|
|
instantlyHeaders,
|
|
instantlyUrl,
|
|
leadOutputs,
|
|
mapLead,
|
|
parseInstantlyResponse,
|
|
} from '@/tools/instantly/utils'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const patchLeadTool: ToolConfig<InstantlyPatchLeadParams, InstantlyLeadResponse> = {
|
|
id: 'instantly_patch_lead',
|
|
name: 'Instantly Patch Lead',
|
|
description: 'Updates fields on an existing Instantly V2 lead.',
|
|
version: '1.0.0',
|
|
params: {
|
|
...instantlyBaseParamFields,
|
|
leadId: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Lead ID',
|
|
},
|
|
first_name: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Lead first name',
|
|
},
|
|
last_name: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Lead last name',
|
|
},
|
|
company_name: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Lead company name',
|
|
},
|
|
job_title: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Lead job title',
|
|
},
|
|
phone: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Lead phone number',
|
|
},
|
|
website: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Lead website',
|
|
},
|
|
personalization: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Lead personalization text',
|
|
},
|
|
lt_interest_status: {
|
|
type: 'number',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Lead interest status value',
|
|
},
|
|
pl_value_lead: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Potential value of the lead',
|
|
},
|
|
assigned_to: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'ID of the user assigned to the lead',
|
|
},
|
|
custom_variables: {
|
|
type: 'json',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Custom variable object with string, number, boolean, or null values',
|
|
},
|
|
},
|
|
request: {
|
|
url: (params) => instantlyUrl(`/api/v2/leads/${params.leadId.trim()}`),
|
|
method: 'PATCH',
|
|
headers: instantlyHeaders,
|
|
body: (params) => {
|
|
const body = compactBody({
|
|
first_name: params.first_name,
|
|
last_name: params.last_name,
|
|
company_name: params.company_name,
|
|
job_title: params.job_title,
|
|
phone: params.phone,
|
|
website: params.website,
|
|
personalization: params.personalization,
|
|
lt_interest_status: params.lt_interest_status,
|
|
pl_value_lead: params.pl_value_lead,
|
|
assigned_to: params.assigned_to,
|
|
custom_variables: params.custom_variables,
|
|
})
|
|
|
|
if (Object.keys(body).length === 0) {
|
|
throw new Error('Provide at least one field to update')
|
|
}
|
|
|
|
return body
|
|
},
|
|
},
|
|
transformResponse: async (response) => {
|
|
const data = await parseInstantlyResponse(response)
|
|
const lead = mapLead(data)
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
lead,
|
|
id: lead.id,
|
|
email_address: lead.email,
|
|
first_name: lead.first_name,
|
|
last_name: lead.last_name,
|
|
campaign: lead.campaign,
|
|
status: lead.status,
|
|
},
|
|
}
|
|
},
|
|
outputs: leadOutputs,
|
|
}
|