Send a typing indicator
Common pattern: type while processing
Show a typing indicator while your bot generates a response, then send the message:Receive typing indicators via webhooks
Subscribe totyping.started and typing.stopped events:
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
Send and receive typing indicators
import { createClient } from "@messages-dev/sdk";
const client = createClient();
await client.startTyping({
from: "+15551234567",
to: "+15559876543",
});
curl -X POST "https://api.messages.dev/v1/typing" \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"from": "+15551234567",
"to": "+15559876543"
}'
await client.stopTyping({
from: "+15551234567",
to: "+15559876543",
});
curl -X POST "https://api.messages.dev/v1/typing" \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"from": "+15551234567",
"to": "+15559876543",
"state": "off"
}'
const client = createClient();
await client.startTyping({
from: "+15551234567",
to: "+15559876543",
});
const reply = await generateReply(incomingMessage);
await client.sendMessage({
from: "+15551234567",
to: "+15559876543",
text: reply,
});
typing.started and typing.stopped events:
import { verifyWebhook } from "@messages-dev/sdk";
app.post("/webhooks", async (req, res) => {
const event = await verifyWebhook(
req.body,
req.headers["x-webhook-signature"],
"your_webhook_secret",
);
if (event.event === "typing.started") {
console.log(`${event.data.handle} is typing...`);
}
if (event.event === "typing.stopped") {
console.log(`${event.data.handle} stopped typing`);
}
res.sendStatus(200);
});
const indicators = await client.listTypingIndicators({
from: "+15551234567",
to: "+15559876543",
});
for (const ind of indicators.data) {
if (ind.isTyping) {
console.log(`${ind.handle} is typing`);
}
}
curl "https://api.messages.dev/v1/typing?from=+15551234567&to=+15559876543" \
-H "Authorization: Bearer sk_live_..."