AI Communication via WebSockets
ProductFlo provides powerful AI capabilities through its WebSocket API, enabling real-time interaction with the Haitch AI assistant and various AI-powered generation features. This page details how to integrate with these AI capabilities.Overview
The WebSocket API supports several AI-powered features:Haitch AI Assistant
Intelligent assistant for product development, engineering, and documentation
Idea Generation
AI-powered brainstorming and product ideation
Document Generation
Create technical documentation, specifications, and reports
Engineering AI
CAD generation, DFM analysis, and engineering assistance
Message Structure
AI communication uses the standard WebSocket message structure with specific code types:Haitch AI Assistant
The Haitch AI assistant provides intelligent assistance for product development questions and tasks.Sending a Haitch Chat Message
Receiving a Haitch Response
Streaming Responses
For longer AI responses, you’ll receive the response in chunks as they’re generated (streaming is enabled by default):Client Implementation for Streaming
Document Generation
Generate professional documentation from product data and requirements.Requesting Document Generation
Receiving Generated Document
Document Types
The system supports various document types:technical_specification
: Detailed product specificationsbom
: Bill of Materialsdfm_analysis
: Design for Manufacturing analysisuser_manual
: End-user documentationdatasheet
: Technical datasheetrequirements
: Requirements documenttest_plan
: Testing procedures and criteriaengineering_drawing
: Technical drawingscompliance_documentation
: Regulatory compliance docs
Idea Generation
Generate product ideas, feature suggestions, and creative solutions.Requesting Idea Generation
Receiving Generated Ideas
Engineering AI Features
Generate CAD models, perform engineering analysis, and create technical designs.Requesting Engineering Analysis
Receiving Engineering Response
Engineering Request Types
The system supports various engineering request types:cad_generation
: Generate 3D CAD modelsdfm_analysis
: Design for Manufacturing analysistolerance_analysis
: Component tolerance stack-up analysisstructural_analysis
: Basic structural integrity checksthermal_analysis
: Thermal performance simulationelectrical_design
: Simple electrical system designpcb_layout
: PCB layout suggestionsmanufacturing_process
: Manufacturing process recommendations
Handling Errors
AI operations can sometimes fail due to various reasons. Error responses follow this format:HAITCH_CHAT_ERROR
: Error in AI assistant processingDOCUMENT_GENERATION_ERROR
: Error in document generationIDEA_GENERATION_ERROR
: Error in idea generationCAD_GENERATION_ERROR
: Error in CAD model generationENGINEERING_ANALYSIS_ERROR
: Error in engineering analysisCONTENT_POLICY_VIOLATION
: Request violates content policiesCONTEXT_LIMIT_EXCEEDED
: Too much context provided
Canceling Operations
Long-running AI operations can be canceled using a cancel message:Providing Context with Files
To enhance AI results, you can attach files for additional context:- First, upload files using the
/files
REST API endpoint - Then reference the file IDs in your WebSocket message:
Best Practices
- Use Request IDs: Always include a unique
request_id
for tracking AI operations, especially long-running ones - Enable Streaming: For responses that might be lengthy, enable streaming for better user experience
- Provide Clear Context: Include relevant product IDs and files to improve AI accuracy
- Handle Errors Gracefully: Implement proper error handling on the client side
- Implement Cancellation: Allow users to cancel operations that are taking too long
- Respect Rate Limits: AI operations are subject to rate limiting - implement retry logic with backoff
- Validate Inputs: Ensure all required fields are properly formatted before sending