Add an AI Cart Assistant to Shopify That Only Answers From Your Policies
A keyword bot breaks when shoppers phrase things differently. An LLM handles "will this reach me by Friday?" fine, but it can also make things up. The fix is to give it your policies and the live cart, and tell it to stick to them.
Send the cart from the storefront
The widget reads /cart.js and posts it with the question to your server.
javascript
async function ask(question) {
const cart = await (await fetch('/cart.js')).json();
const res = await fetch(' https://your-server.com/api/cart-assistant ', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ question, cart }),
});
return (await res.json()).reply;
}
Ground the model on the server javascript import Anthropic from '@anthropic-ai/sdk'; const client = new Anthropic(); // reads ANTHROPIC_API_KEY from env
const POLICIES =
Delivery: 3-5 business days.
COD: available under ₹5,000.
Returns: within 7 days of delivery.
Free shipping…