AI Assistant
How the PalySales AI sales assistant works — model cascade, semantic search, knowledge base, and customization.
PalySales uses OpenAI's language models to power your AI sales assistant. It understands your product catalog, answers customer questions in natural language, and processes orders conversationally across all your connected channels.
How the AI Works
Model Cascade
PalySales uses a two-tier model system to balance cost and quality:
| Model | Role | Handles | Cost (per 1M tokens) |
|---|---|---|---|
| gpt-4o-mini | Primary model | ~85% of messages | $0.15 input / $0.60 output |
| gpt-4o | Fallback model | ~15% of messages | $2.50 input / $10.00 output |
Most conversations are handled by the faster, cheaper model. The system automatically escalates to the more capable model when:
- The primary model's confidence drops below 0.7 (it's not sure of its answer)
- A parse error occurs (the response format is invalid)
- A tool call fails (e.g., product search returned an error)
- Low-confidence phrases are detected (like "I don't understand" or "I'm not sure")
This keeps your costs low while ensuring quality when conversations get complex.
What the AI Knows About Each Conversation
Every time the AI responds, it has access to:
- Your store information — name, contact details, business hours
- The AI personality you've configured — tone and language preferences
- Customer details — name, saved addresses, previous order history
- Conversation state — where the customer is in the buying process (browsing, has items in cart, checking out, etc.)
- Current cart contents — what the customer has added so far
- Your product catalog — found through semantic search based on what the customer asks
- Your knowledge base — policies, FAQs, uploaded documents
- Payment options — dynamically built from your storefront settings
- Recent messages — the last 10 messages for conversation continuity
Tools the AI Can Use
The AI doesn't just chat — it can take actions:
| Tool | What It Does |
|---|---|
search_products | Searches your product catalog based on what the customer asks |
add_to_cart | Adds an item to the customer's cart |
get_cart | Shows the customer what's in their cart |
checkout | Starts the checkout and payment process |
search_knowledge | Searches your knowledge base for policies, FAQs, and store info |
handoff_to_human | Transfers the conversation to a human team member |
Semantic Search
When a customer asks about a product, the AI uses semantic search — not keyword matching. This means it understands the meaning behind questions, not just exact words.
How It Works
- When you save a product, PalySales creates a mathematical representation (called an "embedding") of the product title + description + search terms
- These embeddings are stored in your database using pgvector
- When a customer asks a question, their query is converted to the same type of embedding
- PalySales finds products whose embeddings are most similar to the query
- Products with a similarity score above 0.35 are included as context for the AI
Example: A customer asks "do you have something warm for winter?" — the AI will find jackets, sweaters, and scarves even if none of those products contain the words "warm" or "winter" in their descriptions.
If semantic search doesn't find relevant products, PalySales falls back to tag-based search, then to fuzzy text search.
Regenerating Embeddings
If you've updated many product descriptions and want to refresh the search index:
- In the left sidebar, click Products
- Click the Actions menu (three dots) in the top-right area
- Select Regenerate Embeddings
This can also be done via the API: POST /api/products/generate-embeddings.
Customizing Your AI
AI Personality
To configure your AI assistant's behavior, click AI Assistant in the left sidebar. On the right side of the page, you'll see the personality selector with three options:
| Option | Description |
|---|---|
| Professional | Polite, concise, and business-focused responses |
| Friendly | Warm, conversational, and helpful tone |
| Playful | Casual tone with emojis and enthusiasm |
Below the personality selector, you can also configure:
| Setting | What It Does |
|---|---|
| AI Enabled | Master on/off switch for AI responses |
| Auto Reply | Whether the AI automatically responds to incoming messages |
| Greeting Message | The first message customers see when they start a conversation |
| Fallback Message | Sent when the AI can't generate a response |
| Handoff Keywords | Words or phrases that trigger a handoff to a human (e.g., "speak to manager") |
| Language | The primary language the AI responds in |
| Business Hours | Optional schedule — outside hours, the AI can send an away message |
Click Save in the top-right corner after making changes.
Knowledge Base
The knowledge base is on the left side of the AI Assistant page. This is where you teach your AI additional information beyond your product catalog.
Three ways to add knowledge:
-
Upload a file — drag and drop a PDF, DOCX, or TXT file into the upload area at the top (max 10MB per file). PalySales extracts the text, generates embeddings, and the AI can search it when answering questions.
-
Import from a URL — below the upload area, paste a web URL and click the import button. PalySales fetches the page content and indexes it.
-
Write content directly — click Write content directly to open a text editor. Type or paste your knowledge (minimum 10 words), give it a title, and save it.
Each document shows its status (Learned or Processing), word count, and type. You can preview, edit, refresh (for URL sources), or delete documents using the action buttons on each row.
Store Intelligence
On the right side of the AI Assistant page, below the personality selector, there's a Store Intelligence panel. This shows an automatically generated summary of your store that the AI uses as baseline knowledge.
The summary includes:
- Your store details and contact information
- Your full product catalog with prices and variants
- Delivery options and fees
- Payment methods
- Active deals and promotions
- Policy FAQs
This summary regenerates automatically whenever you update products, delivery settings, payment options, or policies. You can also click the Regenerate button to manually refresh it.
Store Policies
Store policies feed directly into the AI's knowledge. To manage them:
- In the left sidebar, click Settings
- Click Policies
You'll see four policy types:
| Policy | What It Covers |
|---|---|
| Privacy | How you collect, use, and protect customer data |
| Terms | Rules and conditions for using your store |
| Returns | Return windows, refund process, and eligibility |
| Shipping | Delivery methods, costs, and timelines |
Each policy card shows its current status: Published (green), Draft (yellow), or Empty.
To create a policy:
- Click the policy card to open the editor
- Write it manually in the markdown editor, OR
- Click Generate with AI (the sparkles icon) to have the AI write a policy based on your store's country, currency, products, and delivery settings
- Toggle Publish to make it live
- Click Save
When a policy is published, it's automatically synced to the knowledge base. The AI can then reference it when customers ask about shipping times, return policies, etc.
After publishing a policy, you'll see a banner offering to generate FAQ items from it — these are added to your Store Intelligence summary for quick AI reference.
Usage Tracking
All AI usage is tracked per store and resets on the 1st of each month:
| Metric | What It Tracks |
|---|---|
| Conversations | Number of AI-powered conversation sessions |
| Messages | Total individual messages sent and received |
| Input Tokens | Tokens sent to the AI (prompts + context) |
| Output Tokens | Tokens generated by the AI (responses) |
| AI Cost | Total cost of AI operations |
| Embedding Tokens | Tokens used for semantic search operations |
| Embedding Cost | Cost of embedding operations |
| Total Cost | Sum of all AI and embedding costs |
Each event is logged individually with metadata (which model was used, whether escalation occurred, and per-model costs). This data powers the analytics in your dashboard.
Check your usage anytime in Settings → Billing, or via GET /api/usage.
See Billing & Plans for plan limits on conversations and messages.