1. Building
Salla Platform Docs
  • Introduction
  • Resources
  • Foundations
    • Introduction to Salla Partners
    • Planning Your App
  • Building
    • Development Preparation
    • AI for Commerce
    • Core Development
  • Launch & Grow
    • Publishing Your App
    • Growing Your App
Merchant
Merchant
  • Merchant API
  • Embedded SDK
  • Salla OAuth 2.0
Storefront
Storefront
  • Twilight Engine
  • Twilight SDK
  • Web Components
  • Ecommerce Events
  • Component Bundle
  • Checkout APIs
  • Change Log
App Functions
Partner APIs
Partner APIs
  • App API
  • Shipments & Fulfillment APIs
  • Salla AWB
  • Recurring Payments API
  • Billing System Salla partners
  • Communication Apps
Dev Tools
Dev Tools
  • Partners Agent Kit
  • Salla Apps Playbook
  • Salla CLI
Merchant
Merchant
  • Merchant API
  • Embedded SDK
  • Salla OAuth 2.0
Storefront
Storefront
  • Twilight Engine
  • Twilight SDK
  • Web Components
  • Ecommerce Events
  • Component Bundle
  • Checkout APIs
  • Change Log
App Functions
Partner APIs
Partner APIs
  • App API
  • Shipments & Fulfillment APIs
  • Salla AWB
  • Recurring Payments API
  • Billing System Salla partners
  • Communication Apps
Dev Tools
Dev Tools
  • Partners Agent Kit
  • Salla Apps Playbook
  • Salla CLI
Salla - Opensource
Salla - Developers Community
  1. Building

AI for Commerce

This article is written so that any developer, whether you have built AI features before or never called a model API, can follow the full procedure end to end. It is strategic and conceptual first, then fully hands-on.
Orientation Note
This article explains concepts and patterns using Salla APIs generically. The exact implementation, OAuth, webhooks, API calls, is covered in Core Development. Think of this article as "what should I build and why," and Core Development as "how do I wire it into Salla specifically."

Introduction to AI in Commerce#

Why AI Is Transforming E-Commerce#

AI has moved from an experimental add-on to a baseline expectation in online retail. Merchants now expect apps to help them write better content faster, answer customer questions instantly, and understand their sales data without manual analysis.
For Salla Partners, this is a genuine opportunity: apps that embed AI well solve problems that used to require hiring more staff. You do not need a machine learning background, you need to call an API, structure a good prompt, and handle the response. This article walks through exactly that.

How AI Creates Value for Merchants#

1.
Time savings: automating repetitive content or support tasks that would otherwise take hours per week.
2.
Revenue growth: better recommendations, product content, and targeted marketing that increase what a merchant sells.
3.
Insight: surfacing patterns in sales and inventory data a merchant would not otherwise notice.

Common AI Use Cases in Online Stores#

1.
Automatically generating product descriptions from a photo or a few bullet points.
2.
Answering common customer questions instantly, day or night.
3.
Writing marketing copy tailored to a specific campaign or audience.
4.
Recommending products based on browsing or purchase history.
5.
Summarizing sales trends in plain language.
Best Practices
1.
Frame every AI feature around a specific merchant outcome ("write descriptions 5x faster"), not the technology itself.
2.
Start with one well-executed AI use case rather than an all-in-one "AI assistant", focus builds trust faster than breadth.
Common Mistakes
1.
Marketing an app as "AI-powered" without a clear, demonstrable merchant benefit.
2.
Assuming merchants want a chatbot for everything, many prefer AI embedded quietly inside existing workflows over a new conversational interface.

AI Use Cases for Salla Apps#

The table below maps common AI capabilities to the merchant benefit they produce and the app type they suit best. Pick the row closest to your idea, then read the corresponding pattern in Building AI Features.
Product description generation
Faster catalog creation, consistent tone.
Customer support assistants
Faster responses, 24/7 coverage.
Marketing content generation
Faster campaign creation across channels.
Smart product recommendations
Higher average order value.
Sales and inventory insights
Better restocking and pricing decisions.
Image generation and editing
Lower cost product photography.
Merchant productivity assistants
Less time on admin tasks.
Best Practices
1.
Pick the use case that matches your app's existing category, an AI feature bolted onto an unrelated app rarely lands well.
2.
Design the AI output to slot into an existing merchant action (a button next to the manual field) rather than a new tool to learn.
Common Mistakes
1.
Building a use case merchants have not asked for instead of enhancing one they already use daily.
2.
Treating AI output as final, merchants still need a quick review/edit step before publishing.

Choosing the Right AI Model#

LLMs vs. Vision vs. Speech Models#

The first decision in building any AI feature is matching your task to the right model type. Each model type has one input/output shape it is built for.
LLM (text)
Generating or transforming text.
Vision
Understanding or generating images.
Speech
Audio to text, or text to audio.

Hosted APIs vs. Self-Hosted Models#

Most Salla Partners should start with hosted APIs (e.g., Anthropic, OpenAI, Gemini) rather than self-hosting open-source models. Hosted APIs mean:
1.
No infrastructure to manage or scale, send a request, get a response back.
2.
Access to the latest model improvements without retraining anything yourself.
3.
Faster time to market, a working prototype in an afternoon.
Self-hosting only makes sense at significant scale, or when data residency/compliance requirements demand it, the exception, not the default. If unsure, start hosted; migrate later once real usage data justifies the switch.

Speed, Quality, and Cost Trade-Offs#

PriorityWhat to optimize for
Real-time chat supportLow latency over maximum quality
Marketing/product copyQuality over speed, merchants review before publishing anyway
High-volume batch tasks (e.g., tagging 10,000 products)Cost efficiency over per-call quality

Selecting the Right Model - Step by Step#

1
Define the task
Define the task precisely, one sentence: what goes in, what comes out?
2
Match it to a model type
Match it to a model type from the table above (LLM, Vision, or Speech).
3
Estimate volume and response time
Estimate volume and required response time, how many calls per day/month, and does a merchant wait in real time?
4
Choose the smallest model that qualifies
Choose the smallest/cheapest model that meets your quality bar, do not default to the largest "to be safe."
5
Test with real merchant data
Test with real merchant data, run 20–30 real examples through your chosen model and manually review output quality.
Best Practices
1.
Benchmark at least two model options against real product/store data before choosing.
2.
Re-evaluate model choice periodically; pricing and quality shift quickly.
Common Mistakes
1.
Defaulting to the most expensive/largest model "to be safe" without testing a smaller one.
2.
Ignoring latency requirements until after launch, then discovering the model is too slow for real-time use cases.

Building AI Features#

This is the hands-on core of the article: the full procedure from first prompt to production-ready error handling, in the order you will actually build it.
1
Prompt Engineering Fundamentals
A well-structured prompt has four parts: role/context, task, constraints, and format. Use this template:
You are a product copywriter for Saudi e-commerce stores.
Write a product description for the item below.
Constraints: 40-60 words, no exaggerated claims, Arabic and English versions.
Format: return as JSON with "ar" and "en" keys.
Product: {product_name}
Attributes: {attributes}
Keep prompts specific and testable, vague prompts produce inconsistent output, which is expensive to debug at scale. If two merchants' products produce wildly different quality, check whether your constraints are specific enough.
2
Structured Outputs
When your app uses AI output programmatically, request structured output, typically JSON, rather than free text. This avoids fragile parsing logic downstream.
{
  "title": "Wireless Charging Stand",
  "description_ar": "...",
  "description_en": "...",
  "tags": ["electronics", "accessories"]
}
Validate the response against the schema you expect before using it anywhere else in your app. Never assume the model's output is perfectly formed.
3
Function Calling / Tool Use
Function calling lets the model request an action, like "look up this merchant's order status", instead of just generating text. This connects AI to real store data and actions, and is the foundation for the agent patterns in AI Agents & MCP.
In plain terms: you tell the model which functions are available (e.g., get_order_status(order_id)), the model decides when to call one, your app executes it against the real Salla API, and returns the result so the model can finish its response.
4
Conversation Memory
For support assistants or multi-turn interactions, decide what the model needs to remember between messages (previous questions, order context) versus what should be re-fetched fresh (current stock levels, order status). Do not store more merchant/customer data in memory than the interaction requires, this keeps your app simpler and more compliant with Development Preparation's standards.
5
Streaming Responses
For any user-facing AI feature with meaningful response time, stream the response token-by-token instead of waiting for the full output. This dramatically improves perceived speed, a merchant sees words appearing immediately rather than staring at a spinner.
6
Handling AI Failures Gracefully
AI calls can fail, time out, or return low-quality output. Treat this as something that will definitely happen in production:
1.
Set timeouts and fall back to a clear error state, never a silent failure.
2.
For generation tasks, always give merchants an easy manual edit/override path.
3.
Log every failure so you can monitor patterns over time (see Optimizing AI Apps below).
Best Practices
1.
Version your prompts like code, track changes and their effect on output quality.
2.
Always validate structured AI output against your expected schema before using it downstream.
Common Mistakes
1.
Parsing free-text AI output with regex instead of requesting structured output directly.
2.
No fallback UX when an AI call fails, merchants should never hit a dead end.

AI Agents & MCP#

What AI Agents Are#

An agent is an AI system that can take multiple steps and make decisions to complete a task, not just answer a single question.
Where a chatbot answers "What is my order status?", an agent could handle "Find all delayed orders this week and notify the affected customers."

When to Build an Agent Instead of a Chatbot#

Use a chatbot when…
A single question/answer exchange
The merchant reviews every output
Latency matters more than autonomy
Use an agent when…
Multiple steps or decisions required
The workflow runs with minimal supervision
Completing the task matters more than speed
Practical guidance: start with a chatbot. Move to an agent only once you have a clearly repeatable multi-step workflow worth automating, agents are harder to test and monitor, so the complexity should be earned, not assumed.

Introduction to Model Context Protocol (MCP)#

MCP is a standard way for AI models to connect to external tools and data sources, instead of custom integration code for every AI provider, MCP gives you one consistent interface. For Salla Partners, this standardizes how an AI feature reads and acts on store data regardless of which AI provider powers it.

Connecting AI to Salla APIs Through MCP- The Procedure#

How an AI model reaches Salla store data through an MCP server
Figure 3.1 - How an AI model reaches Salla store data through an MCP server
Build an MCP server that exposes specific, well-scoped actions, e.g., "get order by ID" or "list low-stock products." Each maps to one real Salla API call.
Register these actions with your AI model as available tools, the same way you would for function calling.
When a merchant's request needs to store data, the AI model calls the relevant MCP tool instead of having direct, unrestricted API access.
Your MCP server executes the actual Salla API call, returns the result to the model, and the model uses it to complete its response.
This keeps merchant data access auditable and limited to exactly what the feature needs, the AI model never has a blanket key to your entire Salla integration.

Multi-Step Merchant Workflows#

Example: an inventory agent that checks stock levels daily, flags low-stock products, drafts a reorder list, and notifies the merchant, all without manual triggering. Multiple steps, real decisions, minimal supervision: a genuine agent use case.
Best Practices
1.
Scope MCP tool access tightly, expose only the specific actions a feature needs, never blanket API access.
2.
Log every agent action for merchant transparency and easy debugging.
Common Mistakes
1.
Building an agent for a task that is really just a single API call with extra steps.
2.
Giving an AI model write access to sensitive actions (refunds, deletions) without a human confirmation step.

The Salla Partners Agent Kit#

Everything above in this section describes the generic pattern for wiring AI into a merchant-facing app. Salla also ships a dedicated kit that applies the same idea to your own development workflow: it connects AI coding tools directly to the Salla Partners platform, so instead of jumping between docs, the Partners Portal, and your editor, you describe what you want to build and the agent handles the rest.

How It Works: Skills + Partners MCP#

The kit has two parts that work together:
1.
Skills: knowledge files that teach the agent how Salla apps work, the OAuth lifecycle, webhook contracts, App Functions, storefront snippets, billing, publication, and more. The agent reads them silently before acting. Skills can be used on their own as a read-only reference, without connecting the MCP.
2.
Partners MCP: a remote server that gives the agent real actions it can take on your behalf, creating apps, configuring OAuth, subscribing to events, managing settings, and publishing to the App Store. Connecting the MCP is what turns the skills from reference material into an agent that can actually act on the Partners Portal, instead of you hand-writing Portal API calls.

Requirements#

1.
A Salla Partner account.
2.
Node.js 18 or higher.
3.
A supported AI client: Claude Code, Cursor, Codex, Copilot, Gemini CLI, Hermes, Claude Desktop, or any HTTP MCP client.

Getting Started#

Install via plugin
Skills only
Connect MCP
One command installs both skills and MCP together, recommended for most developers.
Full setup steps and reference material live at docs.salla.dev (Dev Tools → Partners Agent Kit) and github.com/SallaApp/salla-partners-agent-kit.

Optimizing AI Apps#

Latency Optimization#

1.
Stream responses wherever the user is waiting in real time.
2.
Cache repeated or predictable AI outputs (FAQ-style answers) instead of regenerating them every time.
3.
Choose smaller/faster models for latency-sensitive features; reserve larger models for asynchronous batch tasks.

Monitoring AI Performance#

Track, at minimum, these four numbers for every AI feature you ship:
Response latency (p50/p95)
What typical and slow requests feel like.
Error/failure rate
Surfaces reliability problems early.
Cost per request
Keeps unit economics visible.
Usage volume by feature
Shows which features merchants use.

Evaluating AI Outputs#

Quality is not "set and forget." Regularly sample AI outputs (e.g., 20 generated descriptions per week) and review against your quality bar. Automated checks (schema validation, keyword presence) catch obvious failures; human review still matters for tone and accuracy.
Best Practices
1.
Set up alerting on error rate and latency, not just cost, a silent quality regression is easy to miss otherwise.
2.
Re-run evaluation samples after any prompt or model change, not just at launch.
Common Mistakes
1.
Monitoring cost alone and missing quality degradation.
2.
Never re-evaluating output quality after launch, even as the model provider updates their model.

AI Resources#

1.
AI SDKs, official SDKs for Anthropic, OpenAI, and Gemini; check each provider's docs for the latest supported features.
2.
Prompt templates, maintain a versioned library of tested prompts for common commerce tasks.
3.
Model provider resources, documentation for model-specific capabilities and pricing.
4.
MCP documentation, the official Model Context Protocol specification and server examples.
5.
Evaluation tools, frameworks for structured AI output testing and regression checks.
6.
AI best-practice guides, provider-published guides on prompt design, safety, and responsible AI use.
7.
Salla Partners Agent Kit: Salla’s official toolkit for building on Salla with a coding agent (Claude Code, Cursor, GitHub Copilot, Codex, Gemini CLI, or Hermes). It packages the platform into skills your agent loads on demand, scaffolding an app, wiring authentication and webhooks, adding billing plans, and building shipping or communication app types, paired with a Partners MCP server so the agent can act directly on the Partners Portal instead of you hand-writing Portal API calls. Describe your goal in plain language and the kit’s router picks the right skill and walks the build step by step. See docs.salla.dev (Dev Tools → Partners Agent Kit) or github.com/SallaApp/salla-partners-agent-kit.
A Prompt Library Is on the Way
A companion prompt library for the Agent Kit is in development and yet to be publicly released, the team is finalizing it before wider rollout. Check back, or watch the Agent Kit’s changelog for the announcement.
Modified at 2026-08-18 14:19:39
Previous
Development Preparation
Next
Core Development