Files
simstudioai--sim/apps/sim/tools/gong/list_calls.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

169 lines
6.2 KiB
TypeScript

import type { GongListCallsParams, GongListCallsResponse } from '@/tools/gong/types'
import { getGongErrorMessage } from '@/tools/gong/utils'
import type { ToolConfig } from '@/tools/types'
export const listCallsTool: ToolConfig<GongListCallsParams, GongListCallsResponse> = {
id: 'gong_list_calls',
name: 'Gong List Calls',
description: 'Retrieve call data by date range from Gong.',
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',
},
fromDateTime: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Start date/time in ISO-8601 format (e.g., 2024-01-01T00:00:00Z)',
},
toDateTime: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'End date/time in ISO-8601 format (e.g., 2024-01-31T23:59:59Z). Defaults to the current execution time when omitted.',
},
cursor: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Pagination cursor from a previous response',
},
workspaceId: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Gong workspace ID to filter calls',
},
},
request: {
url: (params) => {
const url = new URL('https://api.gong.io/v2/calls')
url.searchParams.set('fromDateTime', params.fromDateTime.trim())
url.searchParams.set('toDateTime', params.toDateTime?.trim() || new Date().toISOString())
if (params.cursor?.trim()) url.searchParams.set('cursor', params.cursor.trim())
if (params.workspaceId?.trim()) url.searchParams.set('workspaceId', params.workspaceId.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 list calls'))
}
const calls = (data.calls ?? []).map((call: Record<string, unknown>) => ({
id: call.id ?? '',
title: call.title ?? null,
scheduled: call.scheduled ?? null,
started: call.started ?? '',
duration: call.duration ?? 0,
direction: call.direction ?? null,
system: call.system ?? null,
scope: call.scope ?? null,
media: call.media ?? null,
language: call.language ?? null,
url: call.url ?? null,
primaryUserId: call.primaryUserId ?? null,
workspaceId: call.workspaceId ?? null,
sdrDisposition: call.sdrDisposition ?? null,
clientUniqueId: call.clientUniqueId ?? null,
customData: call.customData ?? null,
purpose: call.purpose ?? null,
meetingUrl: call.meetingUrl ?? null,
isPrivate: call.isPrivate ?? false,
calendarEventId: call.calendarEventId ?? null,
}))
return {
success: true,
output: {
requestId: data.requestId ?? null,
calls,
cursor: data.records?.cursor ?? null,
totalRecords: data.records?.totalRecords ?? calls.length,
currentPageSize: data.records?.currentPageSize ?? null,
currentPageNumber: data.records?.currentPageNumber ?? null,
},
}
},
outputs: {
requestId: {
type: 'string',
description: 'A Gong request reference ID for troubleshooting purposes',
optional: true,
},
calls: {
type: 'array',
description: 'List of calls matching the date range',
items: {
type: 'object',
properties: {
id: { type: 'string', description: "Gong's unique numeric identifier for the call" },
title: { type: 'string', description: 'Call title' },
scheduled: { type: 'string', description: 'Scheduled call time in ISO-8601 format' },
started: { type: 'string', description: 'Recording start time in ISO-8601 format' },
duration: { type: 'number', description: 'Call duration in seconds' },
direction: { type: 'string', description: 'Call direction (Inbound/Outbound)' },
system: { type: 'string', description: 'Communication platform used (e.g., Outreach)' },
scope: {
type: 'string',
description: "Call scope: 'Internal', 'External', or 'Unknown'",
},
media: { type: 'string', description: 'Media type (e.g., Video)' },
language: { type: 'string', description: 'Language code in ISO-639-2B format' },
url: { type: 'string', description: 'URL to the call in the Gong web app' },
primaryUserId: { type: 'string', description: 'Host team member identifier' },
workspaceId: { type: 'string', description: 'Workspace identifier' },
sdrDisposition: { type: 'string', description: 'SDR disposition classification' },
clientUniqueId: {
type: 'string',
description: 'Call identifier from the origin recording system',
},
customData: { type: 'string', description: 'Metadata provided during call creation' },
purpose: { type: 'string', description: 'Call purpose' },
meetingUrl: { type: 'string', description: 'Web conference provider URL' },
isPrivate: { type: 'boolean', description: 'Whether the call is private' },
calendarEventId: { type: 'string', description: 'Calendar event identifier' },
},
},
},
cursor: {
type: 'string',
description: 'Pagination cursor for the next page',
optional: true,
},
totalRecords: {
type: 'number',
description: 'Total number of records matching the filter',
},
currentPageSize: {
type: 'number',
description: 'Number of records in the current page',
optional: true,
},
currentPageNumber: {
type: 'number',
description: 'Current page number',
optional: true,
},
},
}