On-Page Triggers
Placements 03 and 04 — build a floating trigger that opens the assistant from any page, and a homepage banner widget that answers delivery and returns questions up front.
Always-accessible entry points that live on the page itself: the floating trigger and the homepage banner widget.
Floating Trigger
03 · Floating triggerAlways accessible, never intrusive. A floating trigger in the corner of the viewport is reachable from any page — homepage, PDP, PLP, campaign — and opens the assistant only when the shopper asks for it, so it never interrupts the journey.
The SDK has no launcher button. init() mounts the widget iframe into the
container you pass, already visible, and show()/hide() set only that
iframe's display — the SDK never styles your container. So the floating
button, the overlay container, and showing and hiding that container are all
your storefront's code. That is deliberate: it lets the trigger match your brand
and respect your own z-index and safe-area rules.
So the sample below does two things the SDK will not do for you: it passes
height: '100%', and it toggles the container alongside show().
const widget = new SophiWidget();
// position: fixed; inset: 0; display: none — a full-viewport overlay of your own.
// It must start hidden: a transparent fixed container would otherwise swallow
// every click on the storefront underneath it.
const container = document.querySelector('#sophi-widget-container');
await widget.init({
apiKey: 'YOUR_SOPHI_API_KEY',
container,
// The container supplies a definite height; '100%' makes the iframe fill it.
width: '100%',
height: '100%',
});
// init() resolves once the iframe is mounted, so enable the trigger here
trigger.disabled = false;
trigger.addEventListener('click', () => {
container.style.display = 'block';
widget.show();
});
closeButton.addEventListener('click', () => {
widget.hide();
container.style.display = 'none';
});SDK reference
await widget.init(config)— mounts the iframe intocontaineratwidth/height(defaults100%and600px). Passheight: '100%'for a full-viewport placement.widget.show()/widget.hide()— toggle the iframe'sdisplay. Your container's visibility is yours to manage.widget.isReady()—trueonceinit()has resolved and the iframe exists. Use it (or simply the line afterawait init(...)) to gate the trigger.
It is the lowest-effort placement and the only one that covers every page, so it sets a floor before you add the higher-intent entry points on top.
Homepage Widget
04 · HomepageOpen with an invitation, not a button. A widget card in the homepage banner slot puts suggested prompts in front of shoppers the moment they arrive — delivery, returns, exchanges, gift-finding — so the first interaction is a question they already had rather than a chat icon they have to notice. Unlike the floating trigger, it occupies the page's primary slot and sets the tone for the visit.
Each chip is a prompt. Send its text and let the conversation start already in progress:
// Banner chips hand their prompt straight to the widget
bannerChips.addEventListener('click', (event) => {
const chip = event.target.closest('[data-sophi-prompt]');
if (!chip || !widget.isReady()) return;
widget.show();
// sendTextMessage posts to the iframe and returns void — there is nothing to await
widget.sendTextMessage(chip.dataset.sophiPrompt);
});SDK reference
widget.sendTextMessage(query)— each banner chip hands its prompt straight to the chat.widget.sendToggleHistory()— toggles past conversations, for a returning-shopper entry point.
Guided entry and pre-purchase reassurance — delivery, returns, exchanges. The same banner pattern works on the cart page; see Checkout Widget.
Next: Product Pages — product-specific conversations on the PDP and the grid.
Search & Recovery
Placements 01 and 02 — put an Ask AI entry point in the storefront search bar, and recover zero-result searches with a guided Sophi panel instead of a dead end.
Product Pages
Placements 05 and 06 — open the assistant with a product already in context from the PDP buy box, and add an Ask AI overlay to every card on a listing page.