Identity and memory
identify, setMemory, the memory choice, installId, memories and forgetMemory on every platform — parameters, what each returns and when, every error, side effects such as signing out, and threading.
How these behave, and why, is on Identity and users and Memory. This page is the exact surface.
identify
Who the customer is. The trait the agent's Who is the user? setting names —
user_id unless it names another — is the identifier; every other trait becomes
a prompt variable.
| Parameter | Type | Required | Default | |
|---|---|---|---|---|
traits | Map of strings to values, or null | Yes | — | null signs the customer out. Values become strings; nested objects are kept as JSON text in React Native and dropped on native platforms |
memory | Bool, or null | No | null — keep the customer's stored choice | false: this customer's conversations are neither recalled nor stored |
Returns nothing. It applies to the next conversation; one already running keeps the identity it started with.
Side effects
- The identifier is kept as it is and sent only to identify the customer — never
in prompt variables or in what the agent reads about the customer. Graine stores
the identifier your app sends so your team can see who each conversation was
with — Call History shows it — and the
memory service only ever receives a one-way key derived from it. A placeholder
(
guest,unknown,0…), an empty value, a boolean or a decimal is no identifier at all. - Every other trait is masked on the device and becomes a prompt variable.
nullsigns out: the identity is forgotten on the device, the device is released from the customer and unlinked from their calls, and later conversations are anonymous. A different customer signs the previous one out first. Either way the chat on screen clears: the conversation was theirs.memoryis kept for that customer on this install.
Errors none: an identifier that cannot be used is simply no identity.
Threading the main thread on iOS and Android; any thread in React Native, Dart, Kotlin Multiplatform and the browser.
setMemory
The same as identify(currentTraits, { memory: enabled }). Returns nothing;
applies to the next conversation; kept for the customer on this install. The
calls engine receives it too, so a call follows the same choice.
The memory choice
The customer's current choice — what setMemory or identify(…, memory) last
set, true by default. Whether the agent remembers at all is in its settings
(Configuration values).
| Platform | Read it as |
|---|---|
| React Native | client.memoryEnabled: boolean |
| iOS | GraineInApp.shared.memoryChoice: Bool |
| Android | GraineInApp.get().memoryEnabled: Boolean |
| Flutter | GraineInApp.instance.memoryEnabled(): Future<bool> — kept on the platform side |
| Kotlin Multiplatform | Graine.memoryEnabled: Boolean |
installId
This install's id: a random UUID made the first time the app runs, kept across launches, never shown to the agent.
With the calls package installed, the id comes from its native side, so a chat
and a call are one device. Without it, the client keeps the id in the storage
you give the provider; with neither, it is null — the SDK never makes a new
id per launch.
memories
What the agent remembers about the signed-in customer, for this agent's memory scope.
The hook loads once when it mounts and again after forgetMemory.
Returns a list of GraineMemory, newest first, at most 100, each already redacted.
Resolves when Graine answers — one request.
Errors identity_required (nobody identified), device_limit (this install
is not one of the customer's), rate_limited, network, unavailable,
invalid_key, origin_refused — Errors.
Side effects none.
Threading Android calls done on the main thread.
forgetMemory
Deletes everything the agent remembers about the signed-in customer, for this agent's memory scope.
Returns how many memories were deleted.
Resolves once they are deleted.
Errors the same as memories.
Side effects — only when it succeeds: the memories are gone for every agent
sharing this memory scope, the conversation this agent kept for the customer is
forgotten with them, and the chat on screen clears, with any message still
waiting to go. React Native emits memories_changed ({ forgotten: true, deleted }), and useGraineMemories reloads.
When it fails — unavailable (503), device_limit, network,
identity_required — nothing is deleted and the chat on screen stays as it is.
Try again later for unavailable and network.
React Native only
| Member | Returns | |
|---|---|---|
client.identityChannel() | Promise<IdentityChannel> — fields | What will be sent with the next conversation. The client emits identity with the same object when it changes |
client.getRawTraits() | Record<string, unknown> | The traits as your app passed them, before masking — for handing to another part of your app, never for logging |
client.getIdentity() | Record<string, string> | The traits that may reach the agent's prompt: every one identify was given, masked, as strings — except the identifying trait itself, which travels only with the identity. A copy |

