16 KiB
Store Template
The store template provides a complete e-commerce assistant that helps customers browse products, manage shopping carts, and complete purchases through conversational AI.
Topic: E-Commerce & Shopping Assistant
This template is perfect for:
- Online retail stores
- Product catalog browsing
- Shopping cart management
- Order tracking
- Customer support for e-commerce
The Code
ADD TOOL "checkout"
ADD TOOL "search-product"
ADD TOOL "add-to-cart"
ADD TOOL "view-cart"
ADD TOOL "track-order"
ADD TOOL "product-details"
data = FIND "products.csv"
CLEAR SUGGESTIONS
ADD SUGGESTION "products" AS "View products"
ADD SUGGESTION "cart" AS "View my cart"
ADD SUGGESTION "checkout" AS "Checkout"
ADD SUGGESTION "orders" AS "Track my order"
ADD SUGGESTION "help" AS "Shopping help"
SET CONTEXT "store" AS "You are a virtual store sales assistant. Help customers browse products, add items to cart, and complete purchases. Be friendly and helpful. Available products: ${TOJSON(data)}"
BEGIN TALK
**Virtual Store**
Welcome! I can help you with:
• Browse our product catalog
• Add items to your cart
• Complete your purchase
• Track your orders
Select an option or tell me what you're looking for.
END TALK
BEGIN SYSTEM PROMPT
You are a friendly sales assistant in our virtual store.
Welcome customers warmly.
Help them find products.
Provide clear product information.
Guide through purchase process.
Offer assistance when needed.
Product catalog is available in context.
Suggest related products when appropriate.
Confirm items before adding to cart.
END SYSTEM PROMPT
Sample Dialogs
These conversations show how the store template works in real-world scenarios.
Dialog 1: Product Search
Virtual Store
Welcome! I can help you with:
• Browse our product catalog
• Add items to your cart
• Complete your purchase
• Track your orders
I'm looking for wireless headphones
🎧 Great choice! Here are our wireless headphones:
1. ProSound Elite
💰 $149.99 | ⭐ 4.8/5
Active noise canceling, 30hr battery
2. BassBuds Pro
💰 $89.99 | ⭐ 4.5/5
Deep bass, 20hr battery
3. SportFit Wireless
💰 $69.99 | ⭐ 4.6/5
Sweat-proof, secure fit
Would you like more details on any of these?
Dialog 2: Add to Cart and Checkout
Add the ProSound Elite to my cart
✅ Added to cart!
ProSound Elite - $149.99
🛒 Your cart: 1 item ($149.99)
Would you like to:
• Continue shopping
• View cart
• Proceed to checkout
Checkout
📦 Checkout
Order Summary:
1x ProSound Elite - $149.99
Shipping - $9.99
Total: $159.98
Shipping to: 123 Main St, Apt 4B
Please select payment method:
1️⃣ Credit Card (****4521)
2️⃣ PayPal
3️⃣ PIX
1
✅ Order Confirmed!
Order #ORD-2025-0314-001
Total: $159.98
📧 Confirmation sent to your email
🚚 Estimated delivery: March 18-20
Thank you for shopping with us! 🎉
Dialog 3: Order Tracking
Where is my order?
📦 Order Status
Order #ORD-2025-0314-001
✅ Order placed - Mar 14
✅ Payment confirmed - Mar 14
✅ Shipped - Mar 15
🚚 Out for delivery - Mar 17
⏳ Delivered - Expected today
Tracking: ABC123456789
Your package is on the delivery truck and should arrive by 6 PM today!
Dialog 4: Product Recommendations
I need a gift for my brother who loves gaming
🎮 Great! Here are some popular gaming gifts:
Under $50:
• Gaming Mouse Pad XL - $29.99
• LED Light Strip for Setup - $24.99
$50-$100:
• Mechanical Keyboard RGB - $79.99
• Gaming Headset Pro - $69.99
$100+:
• Gaming Mouse Wireless - $129.99
• Streaming Microphone Kit - $149.99
What's your budget? I can help you find the perfect gift! 🎁
Keywords Used
| Keyword | Purpose |
|---|---|
ADD TOOL |
Register e-commerce tools |
FIND |
Load product catalog from CSV |
ADD SUGGESTION |
Create quick action buttons |
SET CONTEXT |
Define store context with product data |
BEGIN TALK |
Welcome message block |
BEGIN SYSTEM PROMPT |
Sales assistant behavior rules |
Template Structure
store.gbai/
├── store.gbdialog/
│ ├── start.bas # Main entry point
│ └── checkout.bas # Checkout process
├── store.gbdata/
│ └── products.csv # Product catalog
└── store.gbot/
└── config.csv # Bot configuration
Checkout Tool: checkout.bas
PARAM confirm AS STRING LIKE "yes" DESCRIPTION "Confirm order placement"
DESCRIPTION "Complete the purchase and process payment"
' Get cart from memory
cart = GET BOT MEMORY("cart_" + user_id)
IF UBOUND(cart) = 0 THEN
TALK "Your cart is empty. Add some items first!"
RETURN NULL
END IF
' Calculate totals
subtotal = 0
FOR EACH item IN cart
subtotal = subtotal + (item.price * item.quantity)
NEXT
shipping = 9.99
IF subtotal > 100 THEN
shipping = 0 ' Free shipping over $100
END IF
total = subtotal + shipping
' Show order summary
TALK "📦 **Order Summary**"
TALK ""
FOR EACH item IN cart
TALK item.quantity + "x " + item.name + " - $" + FORMAT(item.price * item.quantity, "#,##0.00")
NEXT
TALK ""
TALK "Subtotal: $" + FORMAT(subtotal, "#,##0.00")
IF shipping = 0 THEN
TALK "Shipping: FREE ✨"
ELSE
TALK "Shipping: $" + FORMAT(shipping, "#,##0.00")
END IF
TALK "**Total: $" + FORMAT(total, "#,##0.00") + "**"
TALK ""
TALK "Type CONFIRM to place your order."
HEAR confirmation
IF UPPER(confirmation) = "CONFIRM" THEN
' Create order
orderNumber = "ORD-" + FORMAT(NOW(), "YYYY-MMDD") + "-" + FORMAT(RANDOM(100, 999))
WITH order
id = orderNumber
user_id = user_id
items = TOJSON(cart)
subtotal = subtotal
shipping = shipping
total = total
status = "confirmed"
created_at = NOW()
END WITH
SAVE "orders.csv", order
' Clear cart
SET BOT MEMORY "cart_" + user_id, []
' Send confirmation email
SEND MAIL user_email, "Order Confirmed - " + orderNumber,
"Thank you for your order!\n\nOrder: " + orderNumber + "\nTotal: $" + total
TALK "✅ **Order Confirmed!**"
TALK "Order #" + orderNumber
TALK "📧 Confirmation sent to your email"
TALK "🚚 Estimated delivery: 3-5 business days"
TALK ""
TALK "Thank you for shopping with us! 🎉"
RETURN orderNumber
ELSE
TALK "Order cancelled. Your cart items are saved."
RETURN NULL
END IF
Add to Cart Tool: add-to-cart.bas
PARAM product_id AS STRING LIKE "PROD001" DESCRIPTION "Product ID to add"
PARAM quantity AS INTEGER LIKE 1 DESCRIPTION "Quantity to add"
DESCRIPTION "Add a product to the shopping cart"
IF NOT quantity THEN
quantity = 1
END IF
' Find product
product = FIND "products.csv", "id = '" + product_id + "'"
IF NOT product THEN
TALK "Sorry, I couldn't find that product. Please try again."
RETURN NULL
END IF
' Get current cart
cart = GET BOT MEMORY("cart_" + user_id)
IF NOT cart THEN
cart = []
END IF
' Check if product already in cart
found = FALSE
FOR i = 1 TO UBOUND(cart)
IF cart[i].product_id = product_id THEN
cart[i].quantity = cart[i].quantity + quantity
found = TRUE
EXIT FOR
END IF
NEXT
' Add new item if not found
IF NOT found THEN
WITH item
product_id = product_id
name = product.name
price = product.price
quantity = quantity
END WITH
cart = APPEND(cart, item)
END IF
' Save cart
SET BOT MEMORY "cart_" + user_id, cart
' Calculate cart total
cartTotal = 0
cartCount = 0
FOR EACH item IN cart
cartTotal = cartTotal + (item.price * item.quantity)
cartCount = cartCount + item.quantity
NEXT
TALK "✅ Added to cart!"
TALK "**" + product.name + "** - $" + FORMAT(product.price, "#,##0.00")
TALK ""
TALK "🛒 Your cart: " + cartCount + " items ($" + FORMAT(cartTotal, "#,##0.00") + ")"
' Suggest related products
IF product.category THEN
related = FIND "products.csv", "category = '" + product.category + "' AND id <> '" + product_id + "'"
IF UBOUND(related) > 0 THEN
TALK ""
TALK "You might also like: **" + related[1].name + "** - $" + FORMAT(related[1].price, "#,##0.00")
END IF
END IF
RETURN cart
Customization Ideas
Add Product Reviews
ADD TOOL "show-reviews"
' In show-reviews.bas
PARAM product_id AS STRING DESCRIPTION "Product to show reviews for"
reviews = FIND "reviews.csv", "product_id = '" + product_id + "'"
IF UBOUND(reviews) = 0 THEN
TALK "No reviews yet for this product."
RETURN
END IF
avgRating = 0
FOR EACH review IN reviews
avgRating = avgRating + review.rating
NEXT
avgRating = avgRating / UBOUND(reviews)
TALK "⭐ **Customer Reviews** (" + FORMAT(avgRating, "#.#") + "/5)"
TALK ""
FOR EACH review IN FIRST(reviews, 3)
TALK "**" + review.author + "** - " + STRING(review.rating, "⭐")
TALK review.comment
TALK ""
NEXT
Add Discount Codes
PARAM code AS STRING DESCRIPTION "Discount code to apply"
discount = FIND "discounts.csv", "code = '" + UPPER(code) + "' AND valid_until >= '" + FORMAT(NOW(), "YYYY-MM-DD") + "'"
IF NOT discount THEN
TALK "Sorry, that code is invalid or expired."
RETURN NULL
END IF
SET BOT MEMORY "discount_" + user_id, discount
TALK "✅ Discount applied!"
TALK "**" + discount.description + "**"
IF discount.type = "percent" THEN
TALK "You'll save " + discount.value + "% on your order!"
ELSE
TALK "You'll save $" + FORMAT(discount.value, "#,##0.00") + " on your order!"
END IF
Add Wishlist Feature
ADD TOOL "add-to-wishlist"
ADD TOOL "view-wishlist"
' In add-to-wishlist.bas
PARAM product_id AS STRING DESCRIPTION "Product to add to wishlist"
wishlist = GET USER MEMORY("wishlist")
IF NOT wishlist THEN
wishlist = []
END IF
wishlist = APPEND(wishlist, product_id)
SET USER MEMORY "wishlist", wishlist
product = FIND "products.csv", "id = '" + product_id + "'"
TALK "❤️ Added **" + product.name + "** to your wishlist!"
Add Inventory Check
' Before adding to cart, check stock
stock = FIND "inventory.csv", "product_id = '" + product_id + "'"
IF stock.quantity < quantity THEN
IF stock.quantity = 0 THEN
TALK "😔 Sorry, this item is out of stock."
TALK "Would you like to be notified when it's available?"
ELSE
TALK "⚠️ Only " + stock.quantity + " left in stock."
TALK "Would you like to add " + stock.quantity + " instead?"
END IF
RETURN NULL
END IF
Related Templates
- bank.bas - Payment processing integration
- broadcast.bas - Marketing campaigns
- talk-to-data.bas - Sales analytics