Conversations

A conversation is a visitor, remembered.

The agent remembers what was said because the conversation has an identity. That identity lives in localStorage and the SDK manages it — every consumer doing this by hand is how half of them start a new conversation on every page load.

The basics
const chat = tigerbase.conversation();

chat.id;        // "tb-3f1c…" — the stored visitor id
chat.reset();   // start again as somebody new; returns the new id
chat.end();     // stop listening — the conversation is kept

The lifecycle

The id is the conversation. Keep it and the agent remembers; replace it and the agent starts fresh.

Three things move a conversation along. A reload resumes it, because the id survives. reset() replaces it. end() only stops listening — the thread is untouched and the next conversation() picks it up again.

Resuming

There is nothing to do. conversation() returns the same visitor across reloads, and the agent still knows what was discussed — the history is server-side and is put in front of the model on every answer.

NoteBut you cannot read it back yet

The agent remembers; your interface does not. After a reload the conversation continues correctly and your message list starts empty, because there is no route that returns a visitor’s transcript. See the gap below.

TipKeep your own copy for the screen

Until history() exists, store the messages you rendered — in sessionStorage, say — and repaint from them on load. The agent’s memory and your list will agree, because both come from the same turns.

reset() — a new person

Mints a new id, stores it, and returns it. The agent has no memory of anything before it, and the old conversation still exists in the account’s inbox and exports.

Minimal

ts
const newId = chat.reset();

Realistic

A “start over” button
<button
  onClick={() => {
    chat.reset();
    setMessages([]);
    sessionStorage.removeItem("harbor-pine-chat");
  }}
>
  Start over
</button>

Warningreset is not delete

Nothing is removed. This is the right behaviour for a “start over” button and the wrong one for “forget me” — see the gap below.

end() — stop listening

Stops the typing signal, closes the socket if one is open, and drops every listener. Call it when the component unmounts.

In an effect
useEffect(() => {
  return () => chat.end();
}, [chat]);

Noteend() is final for that object

After end(), calling on() on the same object does not reopen the socket. To listen again — the panel was closed and reopened — create a new one with tigerbase.conversation(). It reads the same id, so it is the same conversation.

Managing identity yourself

If your product already knows who this is — a signed-in customer, a ticket — pass it and the SDK will not touch localStorage.

Harbor & Pine — signed-in customers
// The same id on every device the customer signs in on, so the
// conversation about their sofa delivery follows them from laptop to phone.
const chat = tigerbase.conversation({ id: `hp-${customer.chatId}` });
UnguessableAnybody who knows an id can continue that conversation from an allowed domain. Not an incrementing user id, and not an email address.
1 to 64 charactersLetters, digits and . _ : @ - only. The chat route refuses anything else with a 400, before a word is answered — so a bad id fails on the first question, not on the first request for a person.
StableThe same person, the same id, every time. A new one is a new person to the agent.

WarningIt is an identifier, not a credential

The id is sent with every request from the browser, where anybody can read it. Treat it like a session cookie’s name, not its value: an opaque reference you can map back to a customer on your own side.

The gap

NoteThree methods are designed and unbuilt

The server puts a visitor’s history into each answer and has no route that returns it, and none that removes it. So these are described here and do not exist:

history()Would return the stored transcript, so a reload can repaint the conversation rather than starting visually blank.
clear()Would empty this conversation while keeping the same visitor.
delete()Would remove it entirely — and this one is a product question before it is a route: a visitor deleting their own transcript removes it from the account’s exports and analytics too. Whose data is it?

NoteWhy they are not in the first release

They are small. Their shape should come from somebody using the SDK rather than from this page: adding them when asked costs a minor version, and guessing wrong costs a major one.