ShoppingAssistant is the initial Noir chat widget for signed-in shoppers. It provides streaming answers about the store, conversation history, and optional answer feedback. Further visual refinement can be made without changing its storefront API contract.Structure/LayoutA.liquid renders the reusable only when Root.GlobalData.User.IsAuthenticated is true:{% if Root.GlobalData.User.IsAuthenticated %}
{% render 'Reusables\\ShoppingAssistant\\Default' %}
{% endif %}model are required.Reusables.ShoppingAssistant.Translations, backed by Default.json. Liquid serializes and escapes them into data-translations; JavaScript reads them during init().x-data="shoppingassistantreusabledefault".rateable: true. Reopening a conversation does not restore those buttons.noopener noreferrer.shoppingassistantreusabledefault.available, isOpen, view, messages, conversations, conversationId, continuationToken, draft, busy, loading, listLoading, error, lockReason, and status.sessionStorage:noirAssistant.opennoirAssistant.conversationId| Method | Behavior |
|---|---|
init() | Reads translations, checks availability, and restores the selected conversation/panel state. |
request(url, options) | Makes a same-origin JSON request, handles empty success responses, and extracts error codes. |
openPanel() / closePanel() | Controls panel visibility, focus, scroll locking, and the open-state flag. |
loadConversations(append) | Loads or appends a conversation-list page using its continuation token. |
openConversation(id) | Loads the selected conversation; a missing conversation resets to a new one. |
applyConversation(conversation) | Replaces the displayed history and stores the selected identifier. |
refreshTitle(id) | Refreshes the conversation title after a completed answer. |
newConversation() | Clears the current history, draft, errors, and selected identifier. |
closeConversation(id) | Confirms closure, sends the request, and removes the item from the visible list. |
send() | Sends a message and applies streaming events to the displayed turn. |
readStream(response, handlers) / parseFrame(frame) | Decodes chunked SSE frames, including CRLF separators, until a terminal event or end of stream. |
rateAnswer(message, rating) | Sends Positive or Negative; changing the vote is allowed and a failed request restores the previous choice. |
failTurn(user, assistant, code) / showError(code, clearCurrent) | Marks failed messages and displays the matching translated error or composer lock. |
startPolling() / stopPolling() | Recovers an already pending turn after reopening, using bounded polling for up to three minutes. |
relativeTime(value) | Formats conversation-list timestamps. |
renderMarkdown(text) | Renders the supported escaped Markdown subset without an external parser. |
isNearBottom() / scrollToBottom(force) | Keeps new content visible without always overriding the shopper's scroll position. |
fetch directly. Its message request consumes a streaming response body rather than a buffered JSON SDK response.| Method | Storefront route | Purpose |
|---|---|---|
| GET | /api/shopping-assistant/availability | Availability and welcome text. |
| GET | /api/shopping-assistant/conversations | Paged active conversations. |
| GET | /api/shopping-assistant/conversations/{conversationId} | History and pending-turn state. |
| POST | /api/shopping-assistant/conversations/{conversationId}/close | Close a conversation. |
| POST | /api/shopping-assistant/messages | Send { conversationId, text } and receive SSE. |
| PUT | /api/shopping-assistant/conversations/{conversationId}/messages/{messageId}/feedback | Submit { rating }. |
turn_started, status, text_delta, done, and error. The searching_knowledge status selects the searching translation.TextDecoder, and sessionStorage.window.userAuthenticated, supplied by the layout.componentscripts.js bundle, which includes this reusable's JavaScript..sa-* styles.