people.js•4.64 kB
export const peopleTools = [
{
name: "list_people",
description: "List people with optional filtering and pagination",
inputSchema: {
type: "object",
properties: {
filter: { type: "string", description: "Filter query (JSON string)" },
orderBy: { type: "string", description: "Order by field" },
limit: { type: "number", description: "Number of results (max 100)" },
depth: { type: "number", description: "Query depth for relations" },
startingAfter: { type: "string", description: "Cursor for pagination" },
endingBefore: { type: "string", description: "Cursor for pagination" }
}
}
},
{
name: "create_person",
description: "Create a new person in Twenty CRM",
inputSchema: {
type: "object",
properties: {
name: {
type: "object",
properties: {
firstName: { type: "string" },
lastName: { type: "string" }
},
description: "Person's name object with firstName and lastName"
},
emails: {
type: "object",
properties: {
primaryEmail: { type: "string" },
additionalEmails: { type: "array", items: { type: "string" } }
},
description: "Email addresses"
},
phones: {
type: "object",
properties: {
primaryPhoneNumber: { type: "string" },
primaryPhoneCountryCode: { type: "string" },
additionalPhones: { type: "array" }
},
description: "Phone numbers"
},
jobTitle: { type: "string", description: "Job title" },
companyId: { type: "string", format: "uuid", description: "Company ID to associate with" },
linkedinLink: {
type: "object",
properties: {
primaryLinkUrl: { type: "string" },
primaryLinkLabel: { type: "string" }
},
description: "LinkedIn profile link"
},
xLink: {
type: "object",
properties: {
primaryLinkUrl: { type: "string" },
primaryLinkLabel: { type: "string" }
},
description: "X/Twitter profile link"
},
city: { type: "string", description: "City" },
avatarUrl: { type: "string", description: "Avatar image URL" },
chatId: { type: "string", format: "uuid", description: "Chat ID" },
position: { type: "number", description: "Position" }
},
required: ["name"]
}
},
{
name: "get_person",
description: "Get details of a specific person by ID",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Person ID" },
depth: { type: "number", description: "Query depth for relations" }
},
required: ["id"]
}
},
{
name: "update_person",
description: "Update an existing person's information",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Person ID" },
name: { type: "object" },
emails: { type: "object" },
phones: { type: "object" },
jobTitle: { type: "string" },
companyId: { type: "string", format: "uuid" },
linkedinLink: { type: "object" },
xLink: { type: "object" },
city: { type: "string" },
avatarUrl: { type: "string" },
chatId: { type: "string", format: "uuid" },
position: { type: "number" }
},
required: ["id"]
}
},
{
name: "delete_person",
description: "Delete a person from Twenty CRM",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Person ID" }
},
required: ["id"]
}
}
];
export async function executePeopleTool(toolName, params, apiClient) {
switch (toolName) {
case "list_people":
return await apiClient.makeRequest("/people", "GET", null, params);
case "create_person":
return await apiClient.makeRequest("/people", "POST", params);
case "get_person":
return await apiClient.makeRequest(`/people/${params.id}`, "GET", null, { depth: params.depth });
case "update_person":
const { id: personId, ...personData } = params;
return await apiClient.makeRequest(`/people/${personId}`, "PUT", personData);
case "delete_person":
return await apiClient.makeRequest(`/people/${params.id}`, "DELETE");
default:
throw new Error(`Unknown people tool: ${toolName}`);
}
}