Visitors talk to your agent from a button on every page of your store. You need a published agent and its Embed code from Agent โ Deploy โ Website widget.
layout/theme.liquid and paste the embed code just before </body>:<script src="https://evasay.com/voice-widget.js" data-agent="AGENT_SLUG" async></script>
Under Agent โ Deploy โ Allowed websites, add each address your store opens at, one per line, for example https://your-store.myshopify.com and https://www.example.com. With www and without are different addresses. Only these websites can pass values and functions to the agent.
Below the embed code in theme.liquid, give the next call what the page knows. Liquid fills these in on Shopify's side; the values come from the visitor's browser, so the agent treats them as unverified.
<script>
window.evasay = window.evasay || [];
evasay.push(function (agent) {
agent.setVariables({
customer_name: {{ customer.first_name | default: '' | json }},
page: location.pathname
});
agent.update('Cart: {{ cart.item_count }} items', { key: 'cart' });
});
</script>
Add a function of type Runs on your web page named add_to_cart to the agent, with a variant_id parameter, and answer it with Shopify's cart API:
<script>
window.evasay = window.evasay || [];
evasay.push(function (agent) {
agent.registerTool('add_to_cart', async function (args) {
const response = await fetch('/cart/add.js', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ items: [{ id: Number(args.variant_id), quantity: 1 }] })
});
if (!response.ok) throw new Error('Could not add it to the cart');
return { ok: true, checkout: '/checkout' };
});
});
</script>
Give the agent the product and variant IDs it may offer in its knowledge base or instructions. When the theme is replaced or updated, check that the code is still in theme.liquid.