Call identify() when you know the signed-in app user.
await SagepilotChat.identify({
userId: user.id,
email: user.email,
name: user.name,
phone: user.phone,
customProperties: {
plan: "pro",
storeId: "store_123"
}
});
Use behavior.waitForIdentifyBeforeComposer: true for authenticated support flows where the composer should wait for an in-flight identity request before opening.
await SagepilotChat.configure({
key: "workspace_id:channel_id",
behavior: {
waitForIdentifyBeforeComposer: true
}
});
const identifyPromise = SagepilotChat.identify({
userId: user.id,
email: user.email
});
const opened = await SagepilotChat.presentMessageComposer("I need help with my order");
await identifyPromise;
presentMessageComposer() waits only while identify() is already pending. If identity is not pending, it opens immediately.
You can inspect local identity state with SagepilotChat.getIdentityState() or useSagepilotChat().identity. The state includes identified, pending, and customer.
Identity verification
If identity verification is enabled for your workspace, generate userHash on your server and pass only the generated hash to the app:
await SagepilotChat.identify({
userId: user.id,
email: user.email,
userHash: serverGeneratedUserHash
});
Never generate userHash in the mobile app with a signing secret.
Logout
When the app user signs out, clear Sagepilot identity/session state:
await SagepilotChat.logout();
SagepilotChat.destroy();
logout() removes the known customer identity from the current SDK session. destroy() stops polling, clears in-memory state, and removes SDK listeners.