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.
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.- Express
- Next.js (App Router)
server.ts
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
- Script tag
- npm
- Next.js
index.html
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.
onSessionExpiredrenews 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 andRefererheaders. - Stored hashed. Concatflow keeps a SHA-256 of the token, never the token.
When the customer changes
When a customer logs out, calldestroy(). When another customer logs in on the same page, destroy() the assistant and init() a new one with the new customer’s token.
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.