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.
Install EvaSay's Shopify app and choose an agent inside your Shopify admin: the widget is switched on from your theme's app embeds, your store's addresses are allowed, and the agent can look up orders, search products, see the product on screen and the visitor's cart, add to the cart and send the checkout link. Nothing below is needed then; it is for adding the widget by hand.
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.
With EvaSay's Shopify app, Shopify Flow has three EvaSay triggers: