Client Context

An ecommerce seller needed automated handling of battery/product inquiries on Facebook Messenger in Macedonian, Albanian, and English—replacing operators who had to know catalog and all three languages.

The Challenge

Before

Manual triage for vehicle fitment, SKU lookups, and multilingual nuance—high latency and inconsistent answers.

Better

The bot must classify intent, extract structured vehicle fields, query WooCommerce safely, and never loop on bad state.

  • Structured extraction errors break downstream search
  • API and model failures are normal—users still need a graceful path
  • Rate limits and duplicate events from webhooks

Solution Architecture

Conversation state machine with explicit transitions (greeting → gather → search → present → follow-up).

Claude 3.7 Sonnet via OpenRouter with JSON-schema style outputs for language and intent.

Search safety: no catalog query until required fields validate; widening tolerances only after controlled retries.

n8n + JS nodes for firewalling, dedupe, timeouts, and human handoff messaging.

Key Implementation Decisions

  • Prompted structured output vs fine-tuning

    Schema-first responses for predictable parsing and faster iteration than model retraining cycles.

  • Sliding 20-message memory

    Enough context for natural follow-ups without unbounded storage.

  • Retry and widen search policy

    Controlled tolerance expansion (e.g. Ah) before giving up—reduces false negatives.

  • Operator escalation path

    Model/API failure routes to a polite handoff instead of hard errors exposed to users.

Operational Impact

  • Reduced operator load on repetitive SKU and fitment threads.
  • Consistent multilingual responses tied to validated search inputs.
  • Fewer infinite clarification loops via state and attempt caps.

Results

  • Production-shaped conversational commerce automation.
  • Defensive patterns reusable across other webhook + LLM stacks.
  • Measurable reduction in manual handling for targeted intents.

Technology Stack

Orchestration
n8n
Model
Claude 3.7 Sonnet (OpenRouter)
Catalog
WooCommerce REST API
Channel
Facebook Messenger
Logic
JavaScript validation nodes, state machine