Skip to main content
On the per-user door, each answer is filtered on one customer. Your server says which customer is logged in, with your API key. Concatflow returns a short-lived token. Your page gives that token to the assistant, which receives it by postMessage.

Before you start

In the assistant’s dashboard:
  • Isolation is signed. It defines the partition keys, such as customer_id.
  • In Doors, the per-user door is on, and Allowed origins lists your app’s origin.
  • The assistant is published.
You also need an API key and the assistant ID.

1. Install the server SDK

@concatflow/node has no dependencies and needs Node 18 or later.

2. Add a session route

Add one route that opens a session for the logged-in customer. The page calls it on load, and again when the token expires.
Take the partition from your own session, never from the request. req.body.customerId is whatever the visitor typed in their console. req.user.customerId, set by your login, is the truth.
server.ts
The keys of partitions must be exactly the partition keys of the assistant’s isolation. A missing or extra key fails with 403 partition_keys_mismatch. Values are strings or numbers.

3. Show the assistant

index.html
That’s all. Each customer now sees answers on their own rows only. For a complete app with a login, renewal and an isolation check, follow the Next.js tutorial.

What the token is

  • Opaque. It describes nothing. The partition stays on Concatflow’s side.
  • Short-lived. It expires 15 minutes after it was opened. onSessionExpired renews it without the customer noticing. See Session renewal.
  • Never in a URL. The page hands it to the iframe by postMessage, so it stays out of logs and Referer headers.
  • Stored hashed. Concatflow keeps a SHA-256 of the token, never the token.
The conversation outlives tokens. There is one conversation per assistant and per partition. When the customer comes back tomorrow, the assistant shows their last 50 questions.

When the customer changes

When a customer logs out, call destroy(). When another customer logs in on the same page, destroy() the assistant and init() a new one with the new customer’s token.
Use setSession() only to renew the same customer’s token. The iframe loads a conversation’s history once: a token for another customer would leave the previous customer’s questions on screen. In React, give the component a key per customer, as above, so it remounts.

Several partition keys

If the isolation signs two keys, send both:

Errors

sessions.create throws a ConcatflowError on any non-2xx answer. The ones you will meet first: The full list is in Errors.