Set "typing" status
Notify other users whether the current user is typing a message.
POST https://trailblazer.zulipchat.com/api/v1/typing
Clients implementing Zulip's typing notifications protocol should work as follows:
- Send a request to this endpoint with
op="start"
when a user starts typing
a private message or group private message, and also every
TYPING_STARTED_WAIT_PERIOD=10
seconds that the user continues to actively type
or otherwise interact with the compose UI (E.g. interacting with the compose box
emoji picker).
- Send a request to this endpoint with
op="stop"
when a user pauses using the
compose UI for at least TYPING_STOPPED_WAIT_PERIOD=5
seconds or cancels
the compose action (if it had previously sent a "start" operation for that
compose action).
- Start displaying "Sender is typing" for a given conversation when the client
receives an
op="start"
event from the events API.
- Continue displaying "Sender is typing" until they receive an
op="stop"
event
from the events API or TYPING_STARTED_EXPIRY_PERIOD=15
seconds have passed without a new op="start"
event for that conversation.
This protocol is designed to allow the server-side typing notifications implementation
to be stateless while being resilient; network failures cannot result in a user being
incorrectly displayed as perpetually typing.
See
the typing notification docs
for additional design details on Zulip's typing notifications protocol.
Usage examples
#!/usr/bin/env python3
import zulip
# Pass the path to your zuliprc file here.
client = zulip.Client(config_file="~/zuliprc")
# The user has started to type in the group PM with Iago and Polonius
user_id1 = 10
user_id2 = 11
request = {
'op': 'start',
'to': [user_id1, user_id2],
}
result = client.set_typing_status(request)
# The user has finished typing in the group PM with Iago and Polonius
user_id1 = 10
user_id2 = 11
request = {
'op': 'stop',
'to': [user_id1, user_id2],
}
result = client.set_typing_status(request)
print(result)
More examples and documentation can be found here.
const zulipInit = require("zulip-js");
// Pass the path to your zuliprc file here.
const config = { zuliprc: "zuliprc" };
(async () => {
const client = await zulipInit(config);
const user_id1 = 9;
const user_id2 = 10;
const typingParams = {
op: "start",
to: [user_id1, user_id2],
};
// The user has started to type in the group PM with Iago and Polonius
console.log(await client.typing.send(typingParams));
})();
curl -sSX POST https://trailblazer.zulipchat.com/api/v1/typing \
-u BOT_EMAIL_ADDRESS:BOT_API_KEY \
--data-urlencode op=start \
--data-urlencode 'to=[9, 10]'
Parameters
op string required
Example: start
Whether the user has started (start
) or stopped (stop
) to type.
Must be one of: start
, stop
.
to (integer)[] required
Example: [9, 10]
The user_ids of the recipients of the message being typed. Typing
notifications are only supported for private messages. Send a
JSON-encoded list of user_ids. (Use a list even if there is only one
recipient.)
Changes: Before Zulip 2.0, this parameter accepted only a JSON-encoded
list of email addresses. Support for the email address-based format was
removed in Zulip 3.0 (feature level 11).
Response
Example response
A typical successful JSON response may look like:
{
"msg": "",
"result": "success"
}