Skip to content

AskAgent

Use Neocom.askAgent to open the Shop Agent from a storefront control. Pass a search query or product question to send it as the shopper’s first message.

To open the agent without sending a message, follow Full-screen modal. See the AskAgent reference for the available options.

A jacket page can offer Get help choosing a size beside the size selector. With size M selected, the button opens the agent and sends “I’m looking at the Ridge jacket in size M. What measurements will help me find the right fit?”

Pressing Get help choosing a size on the Ridge jacket page opens Shop Agent with the jacket, size M and a detailed size question. The agent asks for a chest measurement and layering preference.

Set the SKU, product title and size from the selected variant. Escape the values for HTML attributes and update them when the shopper changes size. For automatically generated questions, use Product page suggestions.

Product detail page
<button id="ask-about-product" type="button" disabled
data-sku="{{ product.sku }}" data-title="{{ product.title }}"
data-size="{{ product.size }}">Get help choosing a size</button>
<script>
(function () {
const button = document.getElementById("ask-about-product");
function enable() {
button.addEventListener("click", function () {
Neocom.askAgent("YOUR_ASSISTANT_ID", {
display: "modal",
type: "ask_agent_product",
content: `I’m looking at the ${button.dataset.title} in size ${button.dataset.size}. What measurements will help me find the right fit?`,
sku: button.dataset.sku,
title: button.dataset.title
});
});
button.disabled = false;
}
if (window.Neocom) enable();
else window.addEventListener("neocomloaded", enable, { once: true });
})();
</script>

Add the Ask button to your storefront’s existing search form. Keep the form’s regular search action and field name. The example uses a field named q and sends its current value to the agent.

Search form hand-off
<form id="site-search" action="/search" method="get">
<input name="q" type="search" placeholder="Search" autocomplete="off">
<button type="submit">Search</button>
<button type="button" id="ask-agent-search" disabled>Ask our Shop Agent</button>
</form>
<script>
(function () {
const form = document.getElementById("site-search");
const askButton = document.getElementById("ask-agent-search");
let pending = false;
function askAgentWithQuery() {
const query = form.elements.q.value.trim();
if (!query || pending || !window.Neocom) return;
pending = true;
Neocom.askAgent("YOUR_ASSISTANT_ID", {
display: "modal",
type: "ask_agent_search",
content: query
});
setTimeout(function () { pending = false; }, 1000);
}
function enableAskButton() {
askButton.addEventListener("click", askAgentWithQuery);
askButton.disabled = false;
}
if (window.Neocom) enableAskButton();
else window.addEventListener("neocomloaded", enableAskButton, { once: true });
})();
</script>

Test the button and search field with the quickstart verification steps.