Files
simstudioai--sim/apps/sim/tools/gong/lookup_phone.ts
T
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

198 lines
6.3 KiB
TypeScript

import type { GongLookupPhoneParams, GongLookupPhoneResponse } from '@/tools/gong/types'
import { getGongErrorMessage } from '@/tools/gong/utils'
import type { ToolConfig } from '@/tools/types'
export const lookupPhoneTool: ToolConfig<GongLookupPhoneParams, GongLookupPhoneResponse> = {
id: 'gong_lookup_phone',
name: 'Gong Lookup Phone',
description:
'Find all references to a phone number in Gong (calls, email messages, meetings, CRM data, and associated contacts).',
version: '1.0.0',
params: {
accessKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Gong API Access Key',
},
accessKeySecret: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Gong API Access Key Secret',
},
phoneNumber: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Phone number to look up (must start with + followed by country code)',
},
},
request: {
url: (params) => {
const url = new URL('https://api.gong.io/v2/data-privacy/data-for-phone-number')
url.searchParams.set('phoneNumber', params.phoneNumber.trim())
return url.toString()
},
method: 'GET',
headers: (params) => ({
'Content-Type': 'application/json',
Authorization: `Basic ${btoa(`${params.accessKey}:${params.accessKeySecret}`)}`,
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(getGongErrorMessage(data, 'Failed to lookup phone number'))
}
return {
success: true,
output: {
requestId: data.requestId ?? '',
suppliedPhoneNumber: data.suppliedPhoneNumber ?? '',
matchingPhoneNumbers: data.matchingPhoneNumbers ?? [],
emailAddresses: data.emailAddresses ?? [],
calls: data.calls ?? [],
emails: data.emails ?? [],
meetings: data.meetings ?? [],
customerData: data.customerData ?? [],
},
}
},
outputs: {
requestId: {
type: 'string',
description: 'Gong request reference ID for troubleshooting',
},
suppliedPhoneNumber: {
type: 'string',
description: 'The phone number that was supplied in the request',
},
matchingPhoneNumbers: {
type: 'array',
description: 'Phone numbers found in the system that match the supplied number',
items: {
type: 'string',
},
},
emailAddresses: {
type: 'array',
description: 'Email addresses associated with the phone number',
items: {
type: 'string',
},
},
calls: {
type: 'array',
description: 'Related calls referencing this phone number',
items: {
type: 'object',
properties: {
id: {
type: 'string',
description: "Gong's unique numeric identifier for the call (up to 20 digits)",
},
status: { type: 'string', description: 'Call status' },
externalSystems: {
type: 'array',
description: 'Links to external systems such as CRM, Telephony System, etc.',
items: {
type: 'object',
properties: {
system: { type: 'string', description: 'External system name' },
objects: {
type: 'array',
description: 'List of objects within the external system',
items: {
type: 'object',
properties: {
objectType: { type: 'string', description: 'Object type' },
externalId: { type: 'string', description: 'External ID' },
},
},
},
},
},
},
},
},
},
emails: {
type: 'array',
description: 'Related email messages associated with contacts matching this phone number',
items: {
type: 'object',
properties: {
id: {
type: 'string',
description: "Gong's unique 32 character identifier for the email message",
},
from: { type: 'string', description: "The sender's email address" },
sentTime: {
type: 'string',
description: 'Date and time the email was sent in ISO-8601 format',
},
mailbox: {
type: 'string',
description: 'The mailbox from which the email was retrieved',
},
messageHash: { type: 'string', description: 'Hash code of the email message' },
},
},
},
meetings: {
type: 'array',
description: 'Related meetings associated with this phone number',
items: {
type: 'object',
properties: {
id: { type: 'string', description: "Gong's unique identifier for the meeting" },
},
},
},
customerData: {
type: 'array',
description:
'Links to data from external systems (CRM, Telephony, etc.) that reference this phone number',
items: {
type: 'object',
properties: {
system: { type: 'string', description: 'External system name' },
objects: {
type: 'array',
description: 'List of objects in the external system',
items: {
type: 'object',
properties: {
id: {
type: 'string',
description:
"Gong's unique numeric identifier for the Lead or Contact (up to 20 digits)",
},
objectType: { type: 'string', description: 'Object type' },
externalId: { type: 'string', description: 'External ID' },
mirrorId: { type: 'string', description: 'CRM Mirror ID' },
fields: {
type: 'array',
description: 'Object fields',
items: {
type: 'object',
properties: {
name: { type: 'string', description: 'Field name' },
value: { type: 'json', description: 'Field value' },
},
},
},
},
},
},
},
},
},
},
}