Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

sample-conversational-commerce-openclaw-eum

OpenClaw-powered WhatsApp e-commerce bot built on AWS. Customers browse and order through a web storefront, then receive WhatsApp messages and emails for order confirmation, surveys, and refunds. The store owner manages everything through Telegram, where an AI agent (Claude on EKS) handles restock, refund, and order commands. The buyer-facing WhatsApp agent runs on Bedrock AgentCore Runtime using the Strands Agents SDK.

Architecture

How it works

Two AI models, two channels:

  • Customer channel (WhatsApp) -- A Strands Agent (Nova Lite) runs on Bedrock AgentCore Runtime with AgentCore Memory for session continuity. Customer messages arrive via End User Messaging Social, route through SNS to a Dispatcher Lambda, and get processed by the agent. Fast and cheap for high-volume tool-calling.
  • Seller channel (Telegram) -- OpenClaw runs Claude on EKS. The store owner receives stock alerts, review escalations, and order notifications on Telegram. They reply with commands like "restock", "apologize", or "ship order 42", and ClawBot executes them.
  • Web storefront -- CloudFront serves a static site from S3. Checkout calls the Store API through API Gateway.

All three channels share the same Store API Lambda and RDS MySQL database.

Services used

Service Role
End User Messaging Social Managed WhatsApp Business integration
Telegram Bot API Seller notification and command channel
SNS Event bus for inbound WhatsApp messages
Lambda (Dispatcher) Routes WhatsApp events to AgentCore Runtime
Lambda (Store API) Flask REST API for orders, products, reviews, escalations
Bedrock AgentCore Runtime Hosts the Strands Agent container (Nova Lite) for customer chat
Bedrock AgentCore Memory Conversation history per customer phone number
EKS Hosts OpenClaw gateway (Claude) for the seller Telegram channel
RDS MySQL Products, customers, orders, reviews, escalations
SES Order confirmation, shipping, and refund emails
CloudFront + S3 Static web storefront and admin dashboard
API Gateway REST endpoint for the Store API
NLB Exposes OpenClaw on EKS to the Dispatcher Lambda
Secrets Manager Database credentials

Demo walkthrough

A single order touches the web storefront, WhatsApp, email, Telegram, and the admin dashboard. Here is the full flow.

Step 1: Place an order

Open the storefront, add an item to cart, fill in your name, email, and phone number, and click Place Order.

Storefront

Checkout

Step 2: Receive order confirmation

Two things happen immediately:

  • WhatsApp -- The customer gets a confirmation message with the order number, items, and total, followed by a feedback survey ("rate 1-5").
  • Email -- A confirmation email arrives via SES with the same order details.

Order confirmation email

WhatsApp confirmation and survey

Step 3: Low stock alert on Telegram

Every purchase triggers a stock check. If any item drops below threshold (out of stock, fewer than 5 units, or projected to run out within 7 days), the seller gets a Telegram alert with stock levels and sell rates.

The seller can reply restock <product> to add inventory. ClawBot runs the restock tool and confirms the new total.

Telegram stock alert

Step 4: Customer gives negative feedback

The customer replies "1" to the WhatsApp survey. The Store API creates an escalation record and sends the seller a Telegram review alert with the customer's name, phone, rating, and review text.

Telegram review escalation

Step 5: Seller sends refund via Telegram

The seller replies apologize on Telegram. ClawBot looks up the unresolved escalation, then:

  1. Sends a WhatsApp apology message to the customer
  2. Sends a refund confirmation email to the customer via SES
  3. Marks the order as "refunded" in the database
  4. Resolves the escalation

If there are multiple open escalations, ClawBot lists them and asks which one.

Step 6: Check the admin dashboard

The seller opens the admin dashboard to see orders (now showing "refunded" status), escalation history, stock levels, and products.

Admin Dashboard

Admin Orders


Other features

Order via WhatsApp -- Customers can browse and order by texting the WhatsApp business number directly. The Strands Agent on AgentCore handles the full conversation.

WhatsApp order conversation

Telegram seller commands -- The store owner can manage the shop entirely from Telegram:

Command What it does
restock <product> Add 1 unit to inventory (or specify qty)
apologize Send WhatsApp apology + refund email, resolve escalation
stock report Get current inventory levels
orders List recent or pending orders

AI Insights -- OpenClaw generates periodic business insights based on order patterns and customer feedback, visible on the admin dashboard.

AI Insights


Project structure

sample-conversational-commerce-openclaw-eum/
  agents/
    buyer-agent/          Strands Agent for WhatsApp (Python, deployed to AgentCore Runtime)
  cdk/                    CDK stack (EKS, RDS, VPC, Lambda, SNS, SES, S3, CloudFront, AgentCore)
  docker/openclaw/        Dockerfile for OpenClaw container (built by CDK, pushed to ECR)
  lambda/
    dispatcher/           SNS event router (TypeScript)
    store-api/            Flask REST API (Python)
    db-initializer/       Custom resource Lambda for schema + seed data
  openclaw/
    openclaw.json         Agent config (model, tools, channels)
    tools/                Python tool scripts called by OpenClaw (restock, apologize, etc.)
  web/static/
    index.html            Storefront
    admin.html            Admin dashboard
    js/store.js           Storefront logic
    js/admin.js           Admin dashboard logic
  docs/                   Architecture diagram, mockups, screenshots

Working with an AI Coding Assistant

If you are using an AI coding assistant (such as Kiro or Claude Code) to deploy or extend this project, start here.

Recommended setup

Three tools significantly reduce trial-and-error for this deployment.

1. AWS MCP server — Install the AWS MCP server before starting. It gives your AI assistant live access to 15,000+ AWS API operations, current AWS documentation, and sandboxed Python execution — all authenticated via your existing IAM credentials.

claude mcp add-json aws-mcp --scope user \
'{"command":"uvx","args":["mcp-proxy-for-aws==1.6.0","https://aws-mcp.us-east-1.api.aws/mcp","--metadata","AWS_REGION=us-east-1"]}'

2. Amazon SES agent skills — Install the Mail Manager skill for curated, service-team-maintained guidance on correct resource creation order and condition syntax:

npx skills add amazon-ses/skills --skill aws-mail-manager

See readme_agentic_deployment.md for the full step-by-step agentic deployment guide.

3. AGENTS.md — Read AGENTS.md first. It is the machine-readable reference for this project and contains correct API syntax, resource dependency order, IAM patterns, and known pitfalls for Amazon SES Mail Manager.


Deployment

Prerequisites

  • AWS CLI configured with credentials
  • Node.js 18+
  • Docker (or Finch) running
  • A Telegram bot token (from @BotFather)
  • A WhatsApp Business Account linked to AWS End User Messaging Social
  • A verified SES email address

Deploy

git clone <this-repo>
cd sample-conversational-commerce-openclaw-eum

# Copy the context template and fill in your values
cp cdk/cdk.context.example.json cdk/cdk.context.json
# Edit cdk/cdk.context.json with your Telegram bot token, seller chat ID,
# WhatsApp phone number ID, WABA ID, and SES sender email

cd cdk && npm install
npx cdk bootstrap
npx cdk deploy

Security note: Store sensitive values (Telegram bot token, WhatsApp IDs) in cdk/cdk.context.json, which is gitignored. Do not pass tokens as -c CLI flags -- they are visible in shell history and process listings. For CI/CD pipelines, use AWS Secrets Manager or AWS Systems Manager Parameter Store instead.

CDK handles database initialization (schema + seed data), Docker image build, ECR push, and EKS deployment automatically. A first-time deploy takes about 25-30 minutes (EKS cluster creation dominates).

Destroy

cd cdk && npx cdk destroy

No context values needed for destroy.

Post-deploy setup (one-time)

  1. WhatsApp -- CDK automatically links your WABA to the SNS topic. No manual step needed.
  2. Telegram -- Send /start to the bot from the seller's Telegram account.
  3. SES -- Verify your sender email address in the SES console.

Steps 2 and 3 only need to be done once per account. Subsequent deploys reuse existing config.

Verify the deployment

After cdk deploy completes, it prints stack outputs with URLs and resource names. Run this quick smoke test to confirm all services are up (replace the placeholder values with your CDK outputs):

# Grab outputs from the CDK deploy (or run: cd cdk && npx cdk deploy 2>&1 | grep ClawBoutiqueStack)
STOREFRONT_URL="<ClawBoutiqueStack.Storefront>"
STORE_API_URL="<ClawBoutiqueStack.StoreApiUrl>"

echo "=== Storefront ===" \
  && curl -s -o /dev/null -w "%{http_code}" "$STOREFRONT_URL" \
  && echo "" \
  && echo "=== Admin Dashboard ===" \
  && curl -s -o /dev/null -w "%{http_code}" "$STOREFRONT_URL/admin.html" \
  && echo "" \
  && echo "=== Store API (products) ===" \
  && curl -s "${STORE_API_URL}api/products" \
     | python3 -c "import json,sys; d=json.load(sys.stdin); print(f'{len(d)} products loaded')"

Expected output:

=== Storefront ===
200
=== Admin Dashboard ===
200
=== Store API (products) ===
20 products loaded

If the Store API returns 502, wait 30 seconds for the Lambda cold start and retry. Note: the Store API is unauthenticated for demo simplicity — don't seed real customer data, and add API auth before adapting this for production.

Connecting to OpenClaw on EKS

After deploy, CDK prints a ClawBoutiqueClusterConfigCommand output with the aws eks update-kubeconfig command. Copy and run it to configure kubectl.

Then check the pod and view logs:

kubectl get pods -n default -l app=openclaw       # Check pod status
kubectl logs -n default -l app=openclaw --tail=50  # View logs

OpenClaw Control UI

The Control UI requires a secure context (HTTPS or localhost). Use kubectl port-forward to access it locally:

kubectl port-forward svc/openclaw 18789:80

Open http://localhost:18789 in your browser. The UI requires a gateway token for authentication. Get it from the running pod:

kubectl exec deploy/openclaw -c openclaw -- printenv OPENCLAW_GATEWAY_TOKEN

Paste the token into the Control UI settings (gear icon, top right). The token regenerates on every cdk deploy, so you need to grab it again after redeployments.


Using this in Production

This is sample code intended to demonstrate AWS services. Reasonable security steps have been taken (secrets in Secrets Manager, VPC-connected dispatcher, internal NLB, rate limiting, cdk-nag checks), but it has not been hardened for production use.

It is critical that before you use any of this code in Production that you work with your own internal Security and Governance teams to get the appropriate Code and AppSec reviews for your organization.

Although the code has been written with best practices in mind, your own company may require different ones, or have additional rules and restrictions.

You take full ownership and responsibility for the code running in your environment, and are free to make whatever changes you need to.


License

MIT

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages