Presence

This document explains the model for Zulip's presence.

In a chat tool like Zulip, users expect to see the “presence” status of other users: is the person I want to talk to currently online? If not, were they last online 5 minutes ago, or more like an hour ago, or a week? Presence helps set expectations for whether someone is likely to respond soon. To a user, this feature can seem like a simple thing that should be easy. But presence is actually one of the hardest scalability problems for a team chat tool like Zulip.

There's a lot of performance-related details in the backend and network protocol design that we won't get into here. The focus of this is what one needs to know to correctly implement a Zulip client's presence implementation (e.g. web app, mobile app, terminal client, or other tool that's intended to represent whether a user is online and using Zulip).

A client should report to the server every minute a POST request to /users/me/presence, containing the current user's status. The requests contains a few parameters. The most important is "status", which had 2 valid values:

The client receives in the response to that request a data set that, for each user, contains their status and timestamp that we last heard from that client. There are a few important details to understand about that data structure: