Skip to main content

Context enrichment

The backend already gets your catalog from your e-com backend (ingest). Your app can supplement it with live client-side context so the bot answers without asking — what screen the user is on, what product they're viewing, what's in the cart.

Both methods reuse existing backend frames — there is no backend change required.

Zero-PII contract

The whole payload reaches the model. Never put a buyer's name, email, phone, address, payment data, or any personally-identifying order id in AppContext / CartEvent. Keep it to catalog/UI coordinates and a loggedIn boolean (never a user id).

updateContext(AppContext)​

Send it on every screen change, or let the navigation helpers send it. Carries the current screen/route, current product id, viewed category, locale, an auth loggedIn boolean, and merchant custom key/values. The client keeps the last context and sends it to every session it opens.

client.updateContext({
screen: 'ProductDetails',
currentProductId: 'sku-42',
category: 'phones',
locale: 'uk',
loggedIn: true,
custom: { promoActive: true },
});

The latest context is retained and re-sent automatically after a reconnect or resume, so the bot stays oriented across a backgrounding round-trip.

The navigation helpers send the current screen for you, 300 ms after the last move, so most apps never call updateContext by hand.

React Navigation:

import { createNavigationContainerRef, NavigationContainer } from '@react-navigation/native';
import { useMonoverseNavigation } from '@monoverse/react-native';

const navigationRef = createNavigationContainerRef();

function Root() {
useMonoverseNavigation(navigationRef);
return <NavigationContainer ref={navigationRef}>{/* screens */}</NavigationContainer>;
}

The default map sends { screen: route.name, currentProductId: params.productId ?? params.id }, so moving to Product with { id: 42 } sends { screen: 'Product', currentProductId: '42' }. Pass mapRoute as the second argument to send your own AppContext.

Expo Router, an optional peer that the main entry never imports:

import { useMonoverseExpoRouter } from '@monoverse/react-native/expo-router';

export default function Layout() {
useMonoverseExpoRouter();
return <Stack />;
}

It sends { screen: pathname }, plus currentProductId for a /product/<id> path; mapPath overrides it. Both hooks read the client from the nearest MonoverseProvider.

sendCartEvent(...)​

Send a cart snapshot on start, then deltas (add / remove / quantity change), so the bot knows what's in the cart without a round-trip.

// Snapshot on start:
session.sendCartEvent({
type: 'snapshot',
currency: 'UAH',
items: [{ productId: 'sku-42', quantity: 1, price: 14999 }],
});

// Deltas afterward:
session.sendCartEvent({ type: 'add', items: [{ productId: 'sku-7', quantity: 2 }] });

price here is a catalog price, not order/payment data — it stays within the zero-PII contract.

What this maps to on the wire​

SDK callWire frame
updateContext(...){ "type": "client_context", "page_context": {…}, "discovered_urls": [...] }
sendCartEvent(...){ "type": "cart_event", … }
(registered handlers)declared in { "type": "hello", "capabilities": { … } }

See Wire protocol §10 for the frame details.