create-upnify-prospect
Add new prospects to Upnify CRM by inputting their name, email, and other details, facilitating streamlined CRM management within weather-integrated workflows.
Instructions
Create a new prospect in Upnify CRM
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apellidos | No | Last name of the prospect | |
| calle | No | Street address | |
| ciudad | No | City | |
| codigoPostal | No | Postal code | |
| colonia | No | Neighborhood/Colony | |
| comentarios | No | Additional comments about the prospect | |
| correo | Yes | Email address of the prospect | |
| empresa | No | Company name | |
| idPais | No | Country code (e.g., MX, US) | MX |
| movil | No | Mobile phone number | |
| nombre | Yes | First name of the prospect | |
| puesto | No | Job position | |
| sexo | No | Gender (H for male, M for female) | |
| telefono | No | Phone number |
Implementation Reference
- Python implementation of the create-upnify-prospect tool handler. Validates input, prepares payload, authenticates, and sends POST request to Upnify API to create a prospect.async def create_prospect(self, data: Dict[str, Any]) -> Dict[str, Any]: """Create a new prospect in Upnify""" auth_info = await self.auth.get_token_and_user_info() token = auth_info["token"] # Validate required fields if not data.get("nombre") or not data.get("correo"): raise ValueError("Los campos 'nombre' y 'correo' son obligatorios") # Prepare prospect data prospect_data = { "nombre": data["nombre"], "apellidos": data.get("apellidos", ""), "correo": data["correo"], "telefono": data.get("telefono", ""), "movil": data.get("movil", ""), "sexo": data.get("sexo", "H"), "puesto": data.get("puesto", ""), "empresa": data.get("empresa", ""), "ciudad": data.get("ciudad", ""), "idPais": data.get("idPais", DEFAULTS["DEFAULT_COUNTRY"]), "calle": data.get("calle", ""), "colonia": data.get("colonia", ""), "codigoPostal": data.get("codigoPostal", ""), "comentarios": data.get("comentarios", "") } async with httpx.AsyncClient() as client: try: response = await client.post( f"{API_URLS['UPNIFY_BASE']}{ENDPOINTS['CREATE_PROSPECT']}", headers={ "token": token, "Content-Type": "application/json" }, json=prospect_data ) if not response.is_success: error_text = response.text raise Exception(f"Error al crear prospecto: {response.status_code} {response.reason_phrase}. {error_text}") result = response.json() return { "success": True, "message": "Prospecto creado exitosamente", "data": result } except Exception as error: return { "success": False, "error": f"Error al crear prospecto en Upnify: {str(error)}" }
- handlers/prospects.ts:9-96 (handler)TypeScript implementation of the create-upnify-prospect tool handler. Maps input data to Upnify payload, fetches prospect phases, authenticates, and sends POST request to create prospect.async createProspect(tkIntegracion: string, prospectData: ProspectData) { try { const { token, userInfo } = await this.auth.getTokenAndUserInfo(tkIntegracion); // Obtener el catálogo de fases para prospectos let tkFase = UPNIFY_DEFAULTS.TK_FASE; try { const phases = await this.auth.getProspectPhases(tkIntegracion); if (phases && phases.length > 0) { tkFase = phases[0].tkFase; } } catch (phaseError) { // Usar fallback si no se pueden obtener las fases console.error('No se pudieron obtener las fases, usando fallback:', phaseError); } const upnifyPayload = { choice_empresa: "", search_terms: "", empresa: prospectData.empresa || "", tkEmpresa: "", cp: { estatus: "", validador: "", division: "", tipo: "", gasto: "", periodo: "", tipoDeServicio: "", testFecha: "" }, nombre: prospectData.nombre || "", apellidos: prospectData.apellidos || "", titulo: "", sexo: prospectData.sexo || DEFAULTS.GENDER, correo: prospectData.correo || "", url: "", telefono2LadaPais: DEFAULTS.PHONE_PREFIX, telefono2: prospectData.telefono || "", movilLadaPais: DEFAULTS.PHONE_PREFIX, movil: prospectData.movil || "", puesto: prospectData.puesto || "", calle: prospectData.calle || "", colonia: prospectData.colonia || "", idPais: prospectData.idPais || DEFAULTS.COUNTRY, idEstado: "", idMunicipio: "", ciudad: prospectData.ciudad || "", codigoPostal: prospectData.codigoPostal || "", tkFase: tkFase, tkOrigen: "", facebook: "", twitter: "", skype: "", linkedIn: "", googlePlus: "", etiquetas: "", tkEtiquetas: "" }; const response = await fetch(`${API_URLS.UPNIFY_BASE}${ENDPOINTS.PROSPECTS}`, { method: 'POST', headers: { 'token': token, 'Content-Type': 'application/json', }, body: JSON.stringify(upnifyPayload) }); if (!response.ok) { const errorText = await response.text(); console.error('Payload enviado:', JSON.stringify(upnifyPayload, null, 2)); console.error('Token usado:', token); console.error('Respuesta del servidor:', errorText); throw new Error(`Error al crear prospecto: ${response.status} ${response.statusText}. ${errorText}`); } const result = await response.text(); return { success: true, message: 'Prospecto creado exitosamente', response: result, tkEmpresa: userInfo.tkEmpresa }; } catch (error) { throw new Error(`Error al crear prospecto en Upnify: ${error instanceof Error ? error.message : error}`); } }
- Input schema definition for the create-upnify-prospect tool in Python MCP server.Tool( name="create-upnify-prospect", description="Create a new prospect in Upnify CRM", inputSchema={ "type": "object", "properties": { "nombre": {"type": "string", "description": "First name of the prospect"}, "apellidos": {"type": "string", "description": "Last name of the prospect"}, "correo": {"type": "string", "description": "Email address of the prospect"}, "telefono": {"type": "string", "description": "Phone number"}, "movil": {"type": "string", "description": "Mobile phone number"}, "sexo": {"type": "string", "description": "Gender (H for male, M for female)", "enum": ["H", "M"]}, "puesto": {"type": "string", "description": "Job position"}, "empresa": {"type": "string", "description": "Company name"}, "ciudad": {"type": "string", "description": "City"}, "idPais": {"type": "string", "description": "Country code (e.g., MX, US)", "default": "MX"}, "calle": {"type": "string", "description": "Street address"}, "colonia": {"type": "string", "description": "Neighborhood/Colony"}, "codigoPostal": {"type": "string", "description": "Postal code"}, "comentarios": {"type": "string", "description": "Additional comments about the prospect"} }, "required": ["nombre", "correo"] } ),
- main.ts:57-123 (schema)Input schema definition for the create-upnify-prospect tool in TypeScript MCP server.name: 'create-upnify-prospect', description: 'Create a new prospect in Upnify CRM', inputSchema: { type: 'object', properties: { nombre: { type: 'string', description: 'First name of the prospect' }, apellidos: { type: 'string', description: 'Last name of the prospect' }, correo: { type: 'string', description: 'Email address of the prospect' }, telefono: { type: 'string', description: 'Phone number' }, movil: { type: 'string', description: 'Mobile phone number' }, sexo: { type: 'string', description: 'Gender (H for male, M for female)', enum: ['H', 'M'] }, puesto: { type: 'string', description: 'Job position' }, empresa: { type: 'string', description: 'Company name' }, ciudad: { type: 'string', description: 'City' }, idPais: { type: 'string', description: 'Country code (e.g., MX, US)', default: 'MX' }, calle: { type: 'string', description: 'Street address' }, colonia: { type: 'string', description: 'Neighborhood/Colony' }, codigoPostal: { type: 'string', description: 'Postal code' }, comentarios: { type: 'string', description: 'Additional comments about the prospect' } }, required: ['nombre', 'correo'] } },
- python-package/src/upnify_mcp_server/main.py:93-95 (registration)Tool dispatch/registration in Python MCP server's call_tool handler.if name == "create-upnify-prospect": result = await prospects_handler.create_prospect(arguments) return [TextContent(type="text", text=str(result))]