list_opportunita
List and filter sales opportunities in VTENext CRM by status, search terms, or result limits to manage pipeline visibility.
Instructions
Elenca le opportunità con filtri opzionali
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Numero massimo di risultati | |
| stato | No | Stato (es. Prospecting, Qualification, Closed Won) | |
| search | No | Testo da cercare nel nome opportunità |
Implementation Reference
- index.js:23-44 (handler)Tool definition and implementation of 'list_opportunita', which accepts optional filters (limit, stato, search) and executes a VTQL query to fetch potentials.
server.tool( 'list_opportunita', 'Elenca le opportunità con filtri opzionali', { limit: z.number().optional().default(20).describe('Numero massimo di risultati'), stato: z.string().optional().describe('Stato (es. Prospecting, Qualification, Closed Won)'), search: z.string().optional().describe('Testo da cercare nel nome opportunità'), }, async ({ limit, stato, search }) => { let query = `SELECT id, potentialname, sales_stage, amount, closingdate, assigned_user_id FROM Potentials`; const conditions = []; if (stato) conditions.push(`sales_stage = '${stato}'`); if (search) conditions.push(`potentialname LIKE '%${search}%'`); if (conditions.length) query += ' WHERE ' + conditions.join(' AND '); query += ` LIMIT ${limit};`; const results = await client.query(query); return { content: [{ type: 'text', text: JSON.stringify(results, null, 2) }], }; } );