Home
Wiki
Home
Wiki
  1. 3. Reusables
  • Back to home
  • 1. Themes
  • Vs Code
    • Getting Started
  • Kitchenware
    • Layout
      • New Layout
      • Legacy Layout
    • Components
      • Announcement
      • Banner Carousel
      • Banner With Products Carousel
      • Blog Category List
      • Blog List
      • Brand List
      • Brands Carousel
      • Breadcrumb
      • Call To Action
      • Cart
      • Categories List
      • Change Password
      • Checkout
      • Cookie Manager
      • Filter list
      • Footer
      • Forgot Password
      • Form
      • Hero Carousel
      • Icon Block
      • Invitation
      • Last Visited Products
      • Layout
      • Login
      • Map
      • Nav Bar
      • Offer
      • Product Attachments
      • Product Attributes
      • Product Documentation
      • Product Expected
      • Product Modal
      • Products Block
      • Products Carousel
      • Product Single
      • Profile
      • Quote
      • Register
      • Related Products
      • Search
      • Stores
      • Subscribe Newsletter
      • Text with Image
      • Top Bar
      • Video
    • Reusables
      • Getting Started
    • Assets
      • Getting Started
    • SDK
      • Products
        • _findProductsByCategory
        • _findProductsByIds
        • _findProductsByTitle
        • _findProductsByFilter
        • _findProductsByCriteria
        • _findProductsAndCalculate
        • _findProductsThenCalculate
        • _getProductAttributeSet
        • _setLastVisited
      • Categories
        • _findCategoryTreeById
        • _findCategoriesByIds
        • _findCategoryByAlias
        • _findCategoryTreeByAlias
        • _getCategoryContent
      • Collections
        • _getCollectionContent
        • _findCollectionsByIds
        • _findCollectionsByIdsThenCalculate
      • Brands
        • _getBrandContent
        • _findBrandsByIds
      • Cart
        • _addToCartMulti
        • _addToCart
        • _setCart
        • _clearCart
        • _setCartListener
        • _removeFromCart
        • _calculateCart
      • Checkout
        • _startCheckout
        • _updateCheckout
        • _completeCheckout
      • Shopping Lists
        • _getShoppingLists
        • _updateShoppingList
        • _createShoppingList
        • _deleteShoppingList
        • _getShoppingListByAlias
      • Navigation
        • _getFooterMenu
        • _getHeaderMenu
      • Users
        • _getUserById
      • Utils
        • _calculateCurrency
        • _getCurrencySymbol
        • _getCulture
        • _subscribeToNewsletter
        • _findUnitsByIds
  • Noir
    • 0. Introduction
    • 6. FAQ
    • 1. Structure
      • _Overview
      • LayoutA.liquid
      • ComponentsList.liquid
      • Metas.liquid
      • CssVariables.liquid
      • Json.liquid
      • GoogleTagManager.liquid
      • StagingButton.liquid
    • 2. Components
      • _Overview
      • Announcement
      • BannerCarousel
      • BlogCategoryList
      • BlogHighlights
      • BlogList
      • BrandList
      • Breadcrumb
      • Cart
      • CategoriesList
      • ChangePassword
      • Checkout
      • CookieManager
      • CustomTable
      • Faq
      • FilterList
      • Footer
      • ForgotPassword
      • Form
      • IconBlock
      • Invitation
      • LastVisitedProducts
      • Login
      • Map
      • NavBar
      • Offer
      • ProductAttachments
      • ProductAttributes
      • ProductComparison
      • ProductDocumentation
      • ProductMixList
      • ProductsBlock
      • ProductsCarousel
      • ProductSingle
      • Profile
      • Quote
      • Register
      • RelatedProducts
      • SingleBlog
      • Stores
      • TextWithImage
      • ThankYouPage
      • TopBar
      • Wishlist
      • OrderReviews
      • ProductReviews
      • Newsletter
    • 3. Reusables
      • _Overview
      • Addresses
      • AddressForm
      • AnnouncementModal
      • BackToTop
      • BillingRetail
      • BlogPostingStructuredData
      • BrandListStructuredData
      • CollectionStructuredData
      • Company
      • General
      • GroupChildrenTable
      • Login
      • LoginModal
      • MonthlyTransactions
      • Offers
      • Orders
      • Payment
      • ProductAttachments
      • ProductAttributes
      • ProductAvailabilityAction
      • ProductComparisonButton
      • ProductComparisonFloatingButton
      • ProductGridItem
      • ProductGridItemClassic
      • ProductListItem
      • ProductModal
      • ProductStructuredData
      • ProfileInfo
      • PromptModal
      • Quotes
      • Register
      • Services
      • Shipping
      • ShoppingLists
      • ShoppingListsButton
      • ShoppingListsNavbar
      • StoresStructuredData
      • Toast
      • Transactions
      • Users
      • VariantContent
      • VariantContentClassic
      • WishlistButton
      • ProductRating
      • ClientHelpers
      • FaqStructuredData
      • ShoppingAssistant
    • 4. Assets
      • Fonts
      • Images
      • Templates
      • Javascript
        • _Overview
        • theme.js
      • Css - Scss
        • _Overview
        • ThemeClasses
    • 5. SDK
      • _Overview
      • LiquidGlobals
      • ServicesSDK
  1. 3. Reusables

ShoppingAssistant

Purpose#

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.
The assistant answers from the store's configured knowledge. Product-catalog questions and cart actions are not part of this version.

Where it's rendered#

Structure/LayoutA.liquid renders the reusable only when Root.GlobalData.User.IsAuthenticated is true:
{% if Root.GlobalData.User.IsAuthenticated %}
    {% render 'Reusables\\ShoppingAssistant\\Default' %}
{% endif %}
The launcher remains hidden until the availability endpoint confirms that the assistant is available. Signing in alone does not enable it: the store also needs the appropriate licence, enabled assistant settings, a knowledge base, and remaining company allowance.

Inputs (Liquid render parameters)#

No render parameters or component model are required.
Translations come from Reusables.ShoppingAssistant.Translations, backed by Default.json. Liquid serializes and escapes them into data-translations; JavaScript reads them during init().
The welcome message comes from the availability response rather than the translation file.

Template behavior (Liquid + Alpine)#

Binds to x-data="shoppingassistantreusabledefault".
Displays a floating launcher and a side-panel dialog with chat and conversation-list views.
Closes the panel on Escape or a backdrop click and restores the previous body-scroll style.
Supports starting, opening, listing, paginating, and closing conversations.
Limits the composer to 1,000 characters; Enter sends and Shift+Enter inserts a newline.
Disables the composer while sending/loading and after a closed, missing, or full conversation error.
Shows thinking/search status, failures, an AI disclaimer, and the inactivity notice.
Shows answer-rating buttons only for answers completed in the current page with rateable: true. Reopening a conversation does not restore those buttons.
Escapes HTML before rendering a limited Markdown subset: paragraphs, line breaks, lists, bold text, and links. Links accept HTTPS or site-relative destinations and use noopener noreferrer.
Feedback is disabled by default and must be enabled for the store by an administrator.

Data contract (JS runtime)#

The global Alpine object is shoppingassistantreusabledefault.
State includes available, isOpen, view, messages, conversations, conversationId, continuationToken, draft, busy, loading, listLoading, error, lockReason, and status.
The widget stores only the open-panel flag and current conversation identifier in tab-local sessionStorage:
noirAssistant.open
noirAssistant.conversationId
Messages are loaded from the API, not persisted in browser storage by this reusable.

JavaScript#

MethodBehavior
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.

Global Alpine stores#

None.

Services / API calls#

This initial widget uses native fetch directly. Its message request consumes a streaming response body rather than a buffered JSON SDK response.
MethodStorefront routePurpose
GET/api/shopping-assistant/availabilityAvailability and welcome text.
GET/api/shopping-assistant/conversationsPaged active conversations.
GET/api/shopping-assistant/conversations/{conversationId}History and pending-turn state.
POST/api/shopping-assistant/conversations/{conversationId}/closeClose a conversation.
POST/api/shopping-assistant/messagesSend { conversationId, text } and receive SSE.
PUT/api/shopping-assistant/conversations/{conversationId}/messages/{messageId}/feedbackSubmit { rating }.
Handled SSE events are turn_started, status, text_delta, done, and error. The searching_knowledge status selects the searching translation.

Dependencies#

Alpine.js, the browser Fetch/Streams APIs, TextDecoder, and sessionStorage.
window.userAuthenticated, supplied by the layout.
The Noir componentscripts.js bundle, which includes this reusable's JavaScript.
The reusable's Liquid/JavaScript/translation trio and its inline .sa-* styles.
Existing theme color variables and icon font.
Authenticated Shopping Assistant storefront endpoints.

Notes#

A refresh during a turn recovers its saved state through polling; closing the panel does not cancel the active request.
Inactive conversations close automatically after 14 days and leave the active list. Closed records have a separate retention period; this is not immediate physical deletion.
Disabling feedback stops new ratings, but does not delete previously collected feedback.
The widget is an initial implementation retained for evaluation and subsequent frontend refinement.
Modified at 2026-11-25 09:46:41
Previous
FaqStructuredData
Next
Fonts
Built with