orka.Developers
Developers / Web SDK

Session continuity

Available on every plan. A setting of identity verification, off by default.

By default a visitor is a browser. The same person on their phone is a second visitor, with a second conversation. Session continuity gives your logged-in users one conversation that follows them on every device and every browser, and that survives a cleared storage.

How it works

It builds on identity verification: your pages sign the email, and you turn Session continuity on in Settings → Developers → Identity verification. From then on, when the widget loads with a signed email, or receives one from Orka.update():

Orka never restores a conversation from an email alone. Without a valid signature, typing someone's email, or sending it unsigned from a page, gives access to nothing. This is why continuity is a setting of verification, and cannot be turned on without a secret. Turned off, every browser is its own conversation again, verified or not; nothing is deleted.

Set ORKA_SESSION before the install snippet of Web SDK, with the signature your server computed for the logged-in user (see Identity verification):

<script type="text/javascript">
  window.ORKA_SESSION = {
    email: "[email protected]",
    signature: "SIGNATURE_FROM_YOUR_BACK_END",
    name: "Ada Lovelace",
  };
</script>
<!-- then the install snippet of Web SDK, unchanged -->

Or later, after a login in a single page application: the widget switches to the conversation of the person without a reload, and tells your page with the session:change event.

window.Orka.update({ email: user.email, signature: user.orkaSignature, name: user.name });
window.Orka.on("session:change", function (session) {
  // session.conversation_id: the conversation of this person, on every device (null while they never wrote)
});

The conversation a person gets is the oldest one in which they proved that email and wrote: their other conversations, started before a login, never take its place. A browser where they proved it without writing has no conversation to give: until they write somewhere, each browser keeps its own. Your team sees the device they are on right now on the visitor panel.

What happens to the anonymous conversation

A visitor may start chatting before logging in. When they log in and their conversation is restored, the anonymous one is not lost: it stays in your inbox, linked to the same contact. Your team sees both on the contact page. Messages are not merged.

Log out

Call Orka.reset() when your user logs out. The browser forgets the conversation, the next person on that computer starts from scratch. The conversation stays available to its owner at their next login.

async function logout() {
  window.Orka.reset();
  await api.logout();
}

Support staff logged in as a customer

If your team can log in to a customer account, the widget would open that customer's conversation with your support. Do not load the widget in those sessions:

window.ORKA_LOAD = !currentUser.isImpersonated;

Keep the signature private

A signature is a permanent key to the conversation of that person: it only changes when you rotate the secret. Render it for the logged-in user only, never in a public page or a shared cache.