logo

Are you need IT Support Engineer? Free Consultant

Building Interactive AI-Powered Ecommerce with SAP Commerce Cloud and Claude

  • By Sanjay
  • 26/11/2026
  • 12 Views



Overview

Modern Ecommerce platforms are increasingly expected to do more with less developer effort. In SAP Commerce Cloud projects built on the Composable Storefront, adding new customer-facing or agent-facing functionality typically means a developer writes Angular components, wires up OCC API calls, handles error states, and ships a release. For every new business operation — however small — the cycle repeats.

This post describes a different approach: instead of hardcoding each operation, we expose SAP Commerce Cloud's OCC APIs as tools that an AI model (Anthropic's Claude) can reason about and invoke on demand. A customer agent types a natural language request into a chat component embedded in the storefront. Claude decides which OCC operations are needed, in what order, and the Backend-for-Frontend (BFF) server executes them. No new Angular code, no new OCC wiring, no release — just a new tool definition.

This is a V1 prototype aimed at SAP Commerce Cloud and Composable Storefront developers who want to understand what AI-native Ecommerce tooling looks like in practice, and how close it already is to being production-useful.

 

Architecture 

Commerce-Claude-Integration.png

The system has four components: AI Chat Component, BFF server with tool definitions, SAP Commerce Cloud and Claude. The critical interaction is the two-turn Claude loop inside the BFF:

  1. The BFF sends the user's message together with tool definitions (JSON schemas describing what each tool does and what parameters it accepts). Claude reasons about the intent and responds with a tool_use block naming the tool and its arguments. Claude does not execute anything — it only decides.
  2. The BFF executes the tool against OCC, then sends the raw result back to Claude (this time without tools). Claude synthesizes the data into a human-readable answer.

This pattern keeps Claude stateless with respect to OCC credentials and business logic. Claude is purely a reasoning layer.

 

Prototype Implementation

Angular AI Chat Component

The chat feature is loaded globally via a Spartacus outlet so it appears on every page without CMS configuration. AiChatService is a plain Angular service that calls the BFF:

@Injectable({ providedIn: ‘root' })
export class AiChatService {
private http = inject(HttpClient);
private readonly bffUrl=”http://localhost:3000/chat”;

send(message: string, history: ChatMessage[]): Observable<ChatResponse> {
return this.http.post<ChatResponse>(this.bffUrl, { message, history });
}
}

AiChatComponent is a standalone Angular component with ChangeDetectionStrategy.OnPush. The submit handler pushes the user message, calls the service, and appends the assistant reply:

@Component({
…
})
export class AiChatComponent {
private chatService = inject(AiChatService);
…

submit(): void {
const question = this.inputText.trim();
if (!question || this.loadingSubject.value) return;

this.messages = […this.messages, { role: ‘user', content: question }];
this.inputText=””;
this.error=””;
this.loadingSubject.next(true);

this.chatService
.send(question, this.messages.slice(0, -1))
.pipe(finalize(() => this.loadingSubject.next(false)))
.subscribe({
next: (res) => {
this.messages = […this.messages, { role: ‘assistant', content: res.answer }];
this.scrollToBottom();
},
error: () => {
this.error=”Failed to get a response. Please try again.”;
},
});
}
…
}

The component is injected globally via the Footer outlet — no CMS change required.

BFF Server — Tool Definitions and the Claude Loop

Tools

const toolDefinitions = [
…,
{
name: ‘create_and_assign_coupon',
description: ‘Creates a customer coupon and assigns it to a specific customer.',
inputSchema: {
type: ‘object',
properties: {
couponId: { type: ‘string' },
name: { type: ‘string' },
customerId: { type: ‘string', description: ‘Customer email address.' }
},
required: [‘couponId', ‘name', ‘customerId']
}
},
…
];

The two-turn Claude loop in the /chat handler

// Turn 1 — Claude decides which tool to use
const firstResponse = await callClaude([{ role: ‘user', content: message }], true);

if (firstResponse.stop_reason !== ‘tool_use') {
return res.end(JSON.stringify({ answer: extractText(firstResponse) }));
}

// Execute the tool against OCC
const toolResults = await Promise.all(
firstResponse.content
.filter(b => b.type === ‘tool_use')
.map(async (tu) => ({
type: ‘tool_result',
tool_use_id: tu.id,
content: await dispatchTool(tu.name, tu.input)
}))
);// Turn 2 — Claude writes the natural language answer
const finalResponse = await callClaude([
{ role: ‘user', content: message },
{ role: ‘assistant', content: firstResponse.content },
{ role: ‘user', content: toolResults }
], false);

res.end(JSON.stringify({ answer: extractText(finalResponse) }));

OCC Tool Implementations

async function dispatchTool(toolName, toolInput) {
if (toolName === ‘create_and_assign_coupon') {
const { couponId, name, customerId } = toolInput;
const token = await getAgentAccessToken(); // trusted_client
await createCoupon(token, couponId, name); // POST /agent/customercoupons
await assignCoupon(token, couponId, customerId); // POST /agent/customercoupons/{id}/assign
return JSON.stringify({ success: true, couponId, customerId });
}
// …
}

 

Prototype Demonstration

One of the most compelling use cases for interactive AI-Powered Ecommerce is complaint resolution — turning a frustrated customer into a loyal one, in real time. 

For example, a customer contacts customer support, he is unhappy about a delayed order. Instead of routing them to a queue, the customer support handles the entire resolution flow end-to-end: he generates a personalized coupon after acknowledging the complaint, then assigns it directly to the customer's account — all within a single conversation:

Demo.png

 

Key Benefits

Compared to the traditional approach of hardcoding each OCC operation in Composable Storefront:

  • New operations without new Angular code — adding a capability means writing one tool definition and one OCC helper function, not a new component, service, route, and release cycle.
  • Intent-driven orchestration — Claude sequences multi-step OCC operations (create coupon → assign coupon) from a single natural language request. The order and conditions are reasoned, not hardcoded.
  • Graceful natural language output — Claude formats OCC raw data (product lists, confirmation codes) into readable, contextual responses without template logic in Angular.
  • Lower barrier for non-developers — customer agents can trigger complex OCC workflows through plain English. No training on API names or parameter formats required.

 

Further Improvements in Future

  • MCP compliance — exposing the BFF tools via the Model Context Protocol (HTTP+SSE transport) allows any MCP-compatible client (Claude Desktop, Claude Code, other AI agents) to discover and invoke the same tools. The BFF becomes a reusable OCC tool server.
  • More tools — the pattern scales directly: add search_customers, get_order_history, apply_promotion, update_stock_level as new tool definitions. Claude will reason about when to call them without any changes to the routing logic.
  • Multi-turn conversation history — the current implementation sends a single message per request. Passing the full conversation history to Claude enables follow-up questions: “Now assign that coupon to the other customer too” resolves correctly because Claude has context.
  • Error recovery — if an OCC call fails mid-sequence (e.g. the coupon was created but assignment failed), the tool result should include structured error information so Claude can explain what succeeded and what didn't, and optionally retry.
  • Production hardening — rate limiting, input length validation, OCC circuit breakers, and structured logging (with tool name, OCC response time, and Claude token usage per request) are essential before moving beyond prototyping.

 

Summary

This prototype demonstrates that the gap between a natural language request and a multi-step SAP Commerce Cloud operation is now bridgeable with a small amount of glue code. By defining OCC capabilities as tool schemas and delegating orchestration to Claude, we move business logic out of hardcoded Angular/BFF code and into a reasoning layer that can handle requests developers never anticipated. The Composable Storefront, the BFF, and OCC remain unchanged — only the tool registry grows as new capabilities are needed. This is the foundation of an AI-native Ecommerce assistant.

 

Resources

  1. SAP Commerce Cloud OCC REST API Documentation 
  2. SAP Composable Storefront Documentation 
  3. Anthropic Claude API 
  4. Model Context Protocol (MCP) Specification




Source link

Leave a Reply

Your email address will not be published. Required fields are marked *

Chat with us on WhatsApp!