Guides
Who's here and typing
Show who else has a record open and who is typing, including the app's assistant while it writes a reply. Checked as each person, never stored.
A conversation feels alive when you can see the other side is there. app.here() opens a record, such as a job's conversation, and tells you who else has it open and who is typing.
const room = app.here(job.id, (people) => showWhoIsHere(people));
messageBox.addEventListener('input', () => room.typing(true)); // sent at most every few seconds
messageBox.addEventListener('blur', () => room.typing(false));
// When the conversation closes:
room.leave();people is everyone else with that record open, each once however many tabs they have:
for (const p of people) {
// { user, role, name, typing, assistant? }
const who = p.assistant ? p.name : p.role === 'member' ? (p.name ?? 'The customer') : (p.name ?? 'The team');
render(`${who} ${p.typing ? 'is typing' : 'is looking at this'}`);
}What it shows
- Only tabs in front count. A page left open behind others is not someone looking.
- Typing lasts six seconds unless it is said again, so a closed laptop does not leave someone typing for ever. Call
room.typing(false)when a message is sent. - The app's assistant appears, with
assistant: trueand its name, while it writes a reply in the conversation. It shows only when the assistant answers by itself, not while it drafts a reply for your team to check. - Names are first names from your Contacts. A person with no linked contact has none, so show their role.
Who may join
The hub checks the person may read the record before letting them join, again every minute, and at once after your access rules change. Someone who loses access is dropped and told: pass a third argument to hear it.
app.here(job.id, (people) => showWhoIsHere(people), (err) => showMessage(err.message));Nobody is told who tried to join a record they cannot read. Nothing is stored: who's here lives only in the hub's memory.
Limits
A connection has at most 5 records open at once and opens at most 30 a minute. here() shares one connection with live lists.
Two parts of a page can open the same record, such as a conversation and a sidebar showing who is on the job. Each gets people, they count as one record towards the limit, and the record stays open until the last of them calls leave(). typing() is the person's, not the part's, so it is sent at most every few seconds whichever part calls it.