Repository navigation
feat(shopping-assistant): add a storefront shopping assistant example - #7
Merged
Merged
Conversation
A chat bubble on the store page. A shopper asks for "green tea under 20" and gets product cards with Add to cart, or asks "where's my order?" and, when signed in, sees their last orders. - The bubble is a storefront script in its own shadow root. It asks the store for a shopper token with each question and sends it to the app's server, never reading the page. - The server checks the token with authenticateShopper(), searches with GET /api/v1/search/products and reads the customer's orders with filters[customerId], as the app. - Add to cart, View and Open cart go through window.FlyCommerce.run(), so the store updates its cart and drawer, announces the change and offers Undo. - Without storefront.customer it still searches, and points a signed-in shopper to their account page for orders. Runs on the emulator with no account and no AI key; the README shows where a language model goes. Needs the SDK's 0.1.0-next.4.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A chat bubble on the storefront: the example for any app shoppers talk to (support bot, gift finder, AI assistant).
What it does
cart.add, so the cart and drawer update, the store announces the change with Undo, and its limits apply.How
storefront/assistant.jswindow.FlyCommerce.shopperToken()for each question,run('cart.add' | 'nav.goto' | 'ui.openCart'); elements built withtextContentonlysrc/chat.tsallowStorefrontCalls()+authenticateShopper(): the store and customer come only from the verified tokensrc/search.tsGET /api/v1/search/products(catalog.read), then the price limit parsed from the questionsrc/orders.tsGET /api/v1/orders?filters[customerId]=(orders.read) for the token's customersrc/dev.tsNo AI key: replies come from rules in
reply(). The README and AGENTS.md show where a language model goes, with search and orders as its tools and the cart left to the shopper's click.Without
storefront.customerit still searches, and tells a signed-in shopper their orders are on their account page.Depends on
The SDK's
0.1.0-next.4:authenticateShopper,allowStorefrontCalls, and the emulator's products, shopper tokens and store actions (getdokan/flycommerce-sdk#22). Merge after that's published.Tests
test/chat.test.ts(8, against the emulator):storefront.customer;prettier --checkandtscare clean.npm run dev: