Guides

Pass the user and your app state

Identity, app state and screen context make answers specific.

Identify the user

Anonymous devices work out of the box. Bind a known user after login:

Rendel.identify(
  userId: user.id,
  traits: {'plan': 'pro', 'locale': 'de'},
  userHmac: hmacFromYourBackend, // optional, see below
);

With identity verification enabled for your app (we provision the identity secret with you while the console control ships), userHmac is required: your backend computes HMAC_SHA256(userId, identitySecret) and sends it as a lowercase hex digest, so nobody can impersonate another user from a jailbroken client. Call Rendel.reset() on logout.

Provide app state

Context providers run right before each message and ship a compact snapshot:

Rendel.addContextProvider('cart', () async => {
  'items': cart.count,
  'total': cart.formattedTotal,
});

Keep snapshots small (a few hundred bytes). The copilot treats them as data, never as instructions: content in app state cannot steer the model into unregistered behavior.

Screen context

Pass the current screen so "this one" resolves: a user on a product page asking "add this to my cart" works because the copilot knows where they are. There is no dedicated setter yet, so route it through a context provider:

Rendel.addContextProvider(
  'screen',
  () async => {'name': currentRoute, 'product_id': visibleProductId},
);