Skip to main content

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):
You’ll receive multiple stream chunks with pending status:
And when complete, you’ll receive a final message with success status:

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 specifications
  • bom: Bill of Materials
  • dfm_analysis: Design for Manufacturing analysis
  • user_manual: End-user documentation
  • datasheet: Technical datasheet
  • requirements: Requirements document
  • test_plan: Testing procedures and criteria
  • engineering_drawing: Technical drawings
  • compliance_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 models
  • dfm_analysis: Design for Manufacturing analysis
  • tolerance_analysis: Component tolerance stack-up analysis
  • structural_analysis: Basic structural integrity checks
  • thermal_analysis: Thermal performance simulation
  • electrical_design: Simple electrical system design
  • pcb_layout: PCB layout suggestions
  • manufacturing_process: Manufacturing process recommendations

Handling Errors

AI operations can sometimes fail due to various reasons. Error responses follow this format:
Common AI-specific error codes:
  • HAITCH_CHAT_ERROR: Error in AI assistant processing
  • DOCUMENT_GENERATION_ERROR: Error in document generation
  • IDEA_GENERATION_ERROR: Error in idea generation
  • CAD_GENERATION_ERROR: Error in CAD model generation
  • ENGINEERING_ANALYSIS_ERROR: Error in engineering analysis
  • CONTENT_POLICY_VIOLATION: Request violates content policies
  • CONTEXT_LIMIT_EXCEEDED: Too much context provided

Canceling Operations

Long-running AI operations can be canceled using a cancel message:
You’ll receive a confirmation:

Providing Context with Files

To enhance AI results, you can attach files for additional context:
  1. First, upload files using the /files REST API endpoint
  2. Then reference the file IDs in your WebSocket message:

Best Practices

  1. Use Request IDs: Always include a unique request_id for tracking AI operations, especially long-running ones
  2. Enable Streaming: For responses that might be lengthy, enable streaming for better user experience
  3. Provide Clear Context: Include relevant product IDs and files to improve AI accuracy
  4. Handle Errors Gracefully: Implement proper error handling on the client side
  5. Implement Cancellation: Allow users to cancel operations that are taking too long
  6. Respect Rate Limits: AI operations are subject to rate limiting - implement retry logic with backoff
  7. Validate Inputs: Ensure all required fields are properly formatted before sending