conversas.js•3.02 kB
export const conversaTools = [
{
name: "list_conversas",
description: "List conversas 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_conversa",
description: "Create a new conversa in Twenty CRM",
inputSchema: {
type: "object",
properties: {
name: { type: "string", description: "Conversa name" },
conversasId: { type: "string", description: "Conversas ID" },
agent: { type: "string", description: "Agent" },
lead: { type: "string", description: "Lead" },
position: { type: "number", description: "Position" }
}
}
},
{
name: "get_conversa",
description: "Get details of a specific conversa by ID",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Conversa ID" },
depth: { type: "number", description: "Query depth for relations" }
},
required: ["id"]
}
},
{
name: "update_conversa",
description: "Update an existing conversa's information",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Conversa ID" },
name: { type: "string" },
conversasId: { type: "string" },
agent: { type: "string" },
lead: { type: "string" },
position: { type: "number" }
},
required: ["id"]
}
},
{
name: "delete_conversa",
description: "Delete a conversa from Twenty CRM",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Conversa ID" }
},
required: ["id"]
}
}
];
export async function executeConversaTool(toolName, params, apiClient) {
switch (toolName) {
case "list_conversas":
return await apiClient.makeRequest("/conversas", "GET", null, params);
case "create_conversa":
return await apiClient.makeRequest("/conversas", "POST", params);
case "get_conversa":
return await apiClient.makeRequest(`/conversas/${params.id}`, "GET", null, { depth: params.depth });
case "update_conversa":
const { id: conversaId, ...conversaData } = params;
return await apiClient.makeRequest(`/conversas/${conversaId}`, "PUT", conversaData);
case "delete_conversa":
return await apiClient.makeRequest(`/conversas/${params.id}`, "DELETE");
default:
throw new Error(`Unknown conversa tool: ${toolName}`);
}
}