Skip to content

Commit 3043e22

Browse files
committed
one round of fixes based on comments
1 parent 8a23a6a commit 3043e22

File tree

1 file changed

+109
-109
lines changed

1 file changed

+109
-109
lines changed

src/pages/docs/guides/chat/build-task-oriented.mdx

Lines changed: 109 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Ably is trusted by organizations delivering chat to millions of users in realtim
2323

2424
![Ably Architecture Overview Diagram](../../../../images/content/diagrams/architecture-overview.png)
2525

26-
Delivering chat messages in realtime is key to an engaging experience. Ably's [serverless architecture](/docs/platform/architecture) eliminates the need for you to manage websocket servers. It automatically scales to handle millions of concurrent connections without provisioning or maintenance. Ably also handles all of the edge-cases around delivery, failover and scaling.
26+
Delivering chat messages in realtime is key to a smooth online experience. Ably's [serverless architecture](/docs/platform/architecture) eliminates the need for you to manage websocket servers. It automatically scales to handle millions of concurrent connections without provisioning or maintenance. Ably also handles all of the edge-cases around delivery, failover and scaling.
2727

2828
Despite the challenges of delivering these guarantees, Ably is designed to keep costs predictable.
2929
You can choose between MAU-based or per-minute pricing, depending on your needs.
@@ -36,7 +36,7 @@ The most important decision when developing task-oriented chat is the experience
3636

3737
**What are task-oriented chats?** Any chat that serves as a companion to a specific activity or workflow: resolving a support ticket, coordinating a delivery, discussing a chess game, collaborating on a project, or facilitating a marketplace transaction. These chats are typically short-lived (minutes to days) and highly contextual. They can be 1:1 or small group conversations.
3838

39-
For large-scale chat scenarios, see our [building livestream chat guide](/docs/guides/chat/build-livestream).
39+
For large-scale chat scenarios with many users per room, see our [building livestream chat guide](/docs/guides/chat/build-livestream).
4040

4141
**Task-oriented room architecture:** The optimal approach is one chat room per task, where all participants join to communicate within that specific context. Rooms are:
4242

@@ -60,10 +60,10 @@ With MAU-based pricing you will only be charged for the number of unique active
6060

6161
In task-oriented chat, each room is typically low throughput. Scaling comes by running as many rooms as you need at the same time. Ably handles everything from 1:1 conversations and small group discussions to [livestream chats](/docs/guides/chat/build-livestream) with the same reliability and scalability guarantees.
6262

63-
Chat rooms (and Pub/Sub channels) scale horizontally. Ably allows you to have as many rooms as you need running in parallel.
63+
Chat rooms scale horizontally. Ably allows you to have as many rooms as you need running in parallel.
6464

6565
* **Proven at scale:** Ably delivers over 500 million messages per day for customers.
66-
* **Rate limiting:** Prevent spam and maintain conversation quality with per-user rate limits or global throttling appropriate for your use case.
66+
* **Rate limiting:** Prevent spam and maintain conversation quality with global or per-user throttling appropriate for your use case.
6767

6868
## Authentication
6969

@@ -97,7 +97,7 @@ const currentTime = Math.round(Date.now() / 1000);
9797
const claims = {
9898
"iat": currentTime, /* current time in seconds */
9999
"exp": currentTime + 14400, /* time of expiration in seconds */
100-
"x-ably-capability": "{\"[chat]foo\":[\"publish\", \"subscribe\"]}",
100+
"x-ably-capability": "{\"foo\":[\"publish\", \"subscribe\"]}",
101101
"x-ably-clientId": "your-client-id",
102102
}
103103

@@ -111,79 +111,23 @@ console.log('JWT is: ' + ablyJwt);
111111
```
112112
</Code>
113113

114-
How you authenticate is also key. To balance security and experience, you want short-lived tokens that can be easily revoked if a users is misbehaving or needs their permissions changed, but automatically expire after a period of time. This means that if a token is compromised, it will only be valid for a limited time. **In production apps, you should not use API keys for client-side authentication**. You can use them server-side, but as they are long-lived and require explicit revocation, exposure to untrusted users poses a continuing risk.
114+
How you authenticate is also key. To balance security and experience, you want short-lived tokens that can be easily revoked if a user is misbehaving or needs their permissions changed, but automatically expire after a period of time. This means that if a token is compromised, it will only be valid for a limited time. **In production apps, you should not use API keys for client-side authentication**. You can use them server-side, but as they are long-lived and require explicit revocation, exposure to untrusted users poses a continuing risk.
115115

116116
With Ably Chat, authentication is best achieved using JSON Web Tokens (JWTs). These are tied to a particular clientID and come with a set of [capabilities](/docs/chat/setup#authentication) that control what a client can and cannot do - for example whether they can send messages, join a certain room or moderate. Ably's SDKs handle the timing and process of requesting a new token for you, refreshing it when it expires. All you need to do is provide a server-side endpoint that can generate the JWT for the client. This enables clients to use your existing authentication systems or user sessions to generate their Ably token.
117117

118-
## Moderation: maintaining quality conversations
119-
120-
Effective moderation ensures your task-oriented chats remain professional, safe, and productive. While task-oriented chats typically involve fewer participants than livestreams, maintaining conversation quality is crucial for successful task completion and keeping your users safe.
121-
122-
Ably supports [moderating messages](/docs/chat/moderation) both before and after publication, making it easy to integrate with AI-powered or human moderation systems.
123-
124-
* **After-publish moderation:** Messages appear instantly, then are removed if flagged as inappropriate. Best for most task-oriented scenarios where immediacy matters.
125-
* **Before-publish moderation:** Messages are held until approved. Use this for high-stakes tasks where every message must be vetted.
126-
127-
### Key moderation considerations for task-oriented chat
128-
129-
1. **Platform standards**
130-
* What level of moderation is appropriate for your audience?
131-
* How will you handle different types of content? For example:
132-
* **Hate speech and harassment:** Detecting discriminatory language, threats, or targeted abuse.
133-
* **Discrimination:** Detecting discriminatory language, threats, or targeted abuse.
134-
* **Inappropriate content:** Flagging adult content, violence, or graphic material.
135-
* **Toxicity:** Measuring overall message sentiment and hostility
136-
137-
138-
2. **Technical integration**
139-
* **Latency impact:** AI moderation adds up to 100ms to message delivery.
140-
* **Integration options:** Choose from pre-built integrations or connect your existing moderation systems via webhooks, serverless functions, or queues
141-
142-
3. **Task-specific approaches**
143-
* **Customer support:** Protect both customers and agents from abuse and harassment.
144-
* **Gaming:** Prevent harassment while allowing enthusiastic expressions.
145-
* **Marketplace:** Ensure rules are being followed such as detecting if outside-platform contact info is exchanged.
146-
147-
### How Ably enhances task-oriented moderation
148-
149-
Ably's flexible moderation system adapts to your task requirements:
150-
151-
* **Per-room policies:** Different moderation rules for different task types or user roles
152-
* **Fallback handling:** Configure what happens when moderation services are unavailable
153-
* **Custom integration:** Connect your existing moderation infrastructure via webhooks, serverless functions, or message queues
154-
* **Role-based permissions:** Give moderators special capabilities to manage conversations
155-
156-
<Code>
157-
```javascript
158-
import { ErrorCode } from '@ably/chat';
159-
160-
const room = await chatClient.rooms.get('support-ticket-123');
161-
162-
await room.messages.send({text: 'Can you help me with my order?'}).then((message) => {
163-
console.log('Message sent:', message);
164-
}).catch((error) => {
165-
if (error.code === ErrorCode.MessageRejectedByModeration) {
166-
console.log('Message needs review:', error.message);
167-
return;
168-
}
169-
console.error('Message failed to send:', error);
170-
});
171-
```
172-
</Code>
173-
174118
## Presence: Know who's available for your task
175119

176120
Ably's [presence](/docs/chat/rooms/presence) feature shows you who's currently active in your task-oriented chat. This is especially valuable for scenarios where task completion depends on participant availability:
177121

178-
* **Support tickets:** See when agents are online and available to help
179-
* **Deliveries:** Know if the delivery driver or customer is actively monitoring the chat
180-
* **Gaming sessions:** See which players are currently active in the game
181-
* **Collaborative work:** Know who's available for real-time discussion
122+
* **Support tickets:** See when agents are online and available to help.
123+
* **Deliveries:** Know if the delivery driver or customer is actively monitoring the chat.
124+
* **Gaming sessions:** See which players are currently active in the game.
125+
* **Collaborative work:** Know who's available for real-time discussion.
182126

183127
Beyond just online/offline status, presence can include rich information:
184128

185-
* **Current status:** "Available", "In a meeting", "Driving", "On break"
186-
* **Task context:** "Working on ticket #123", "In delivery zone A"
129+
* **Current status:** "Available", "In a meeting", "Driving", "On break".
130+
* **Task context:** "Working on ticket #123", "In delivery zone A".
187131
* **User info:** Use presence to show an avatar, display name, role, or other information about the user.
188132

189133
This contextual presence information helps participants understand not just who's online, but who's ready and able to engage with the current task.
@@ -192,9 +136,9 @@ This contextual presence information helps participants understand not just who'
192136

193137
Typing indicators are now a common feature in most chat applications. They show when someone is actively composing a message, helping to:
194138

195-
* **Manage expectations:** Users know when a response is being prepared
196-
* **Reduce duplicate messages:** See that someone is already addressing the question
197-
* **Improve flow:** Better conversation pacing in support and collaborative scenarios
139+
* **Manage expectations:** Users know when a response is being prepared.
140+
* **Reduce duplicate messages:** See that someone is already addressing the question.
141+
* **Improve flow:** Better conversation pacing in support and collaborative scenarios.
198142

199143
In Ably Chat typing indicators are a core feature with a simple API:
200144

@@ -219,9 +163,9 @@ Message reactions are a great way to enhance engagement in a task-oriented chat
219163

220164
**Message reactions** provide granular feedback on specific content:
221165

222-
* **Validate information:** ✅ for confirmed details in deliveries or transactions
223-
* **Request clarification:** ❓ for questions about specific messages
224-
* **Show appreciation:** ⭐ for helpful responses in support
166+
* **Validate information:** ✅ for confirmed details in deliveries or transactions.
167+
* **Request clarification:** ❓ for questions about specific messages.
168+
* **Show appreciation:** ⭐ for helpful responses in support.
225169

226170
Send a message reaction:
227171
<Code>
@@ -233,38 +177,22 @@ await room.messages.reactions.send(message.serial, {name: '✅'});
233177

234178
Message reactions in Ably Chat come in three types: `unique`, `distinct` and `multiple`, to suit different use cases: from one reaction per message to multiple reactions per message with or without counts. See the [Message reactions](/docs/chat/rooms/message-reactions) documentation for more details.
235179

236-
## Room reactions
237-
238-
Room reactions are a great engagement feature for chats that accompany calls, meetings, collaborative tools, and games. They are a way to quickly express a sentiment to the entire room at a point in time without adding to chat history or being tired to a message.
239-
240-
<Code>
241-
```javascript
242-
// Subscribe to room reactions
243-
room.reactions.subscribe((event) => {
244-
console.log('Room reaction received:', event.reaction.name, "from", event.reaction.clientId);
245-
});
246-
247-
// Send a room reaction
248-
await room.reactions.send({name: '👍'});
249-
```
250-
</Code>
251-
252180
## Message history: essential task context <a id="history"/>
253181

254182
Message history is crucial for task-oriented chats, ensuring continuity and context even when participants join mid-task or return after interruptions.
255183

256184
Ably stores [chat history](/docs/chat/rooms/history) for 30 days by default, with options to extend up to a year.
257185

258-
* **Task continuity:** New participants can quickly understand the current state and previous decisions
259-
* **Context preservation:** Users returning to a task don't lose important information
260-
* **Audit trail:** Complete conversation records for compliance, training, or dispute resolution
186+
* **Task continuity:** New participants can quickly understand the current state and previous decisions.
187+
* **Context preservation:** Users returning to a task don't lose important information.
188+
* **Audit trail:** Complete conversation records for compliance, training, or dispute resolution.
261189

262190
For task-oriented scenarios, history is almost always beneficial:
263191

264-
* **Support tickets:** Agents can see the full conversation history to understand the issue
265-
* **Collaborative work:** Team members can catch up on decisions and progress
266-
* **Gaming sessions:** Players can review moves and strategy discussions
267-
* **Marketplace transactions:** Complete communication record for orders and deliveries
192+
* **Support tickets:** Agents can see the full conversation history to understand the issue, after handover from automated/AI support or another agent.
193+
* **Collaborative work:** Team members can catch up on decisions and progress.
194+
* **Gaming sessions:** Players can review moves and strategy discussions.
195+
* **Marketplace transactions:** Complete communication record for orders and deliveries.
268196

269197
<Code>
270198
```javascript
@@ -287,6 +215,90 @@ You can use our [React UI Kit](/docs/chat/react-ui-kit) to easily create a [full
287215
that handles subscrbing to messages, loading history, message updates and deletes, message reactions, and more.
288216
See the [React UI Kit](/docs/chat/react-ui-kit) for more details.
289217

218+
## Enriching tasks with Ably's realtime services
219+
220+
Ably's comprehensive platform enables you to combine chat with other realtime features to create rich, interactive task experiences.
221+
222+
**Pub/Sub channels** add interactive elements:
223+
- **Live polls:** Quick feedback during collaborative decisions
224+
- **Status updates:** Real-time progress indicators for tasks
225+
- **Interactive ratings:** Instant feedback collection
226+
- **Live auctions:** Real-time bidding in marketplace scenarios
227+
228+
These combined services transform basic chat into comprehensive task management platforms, where communication, coordination, and real-time updates work together seamlessly.
229+
230+
## Moderation: maintaining quality conversations
231+
232+
Effective moderation ensures your task-oriented chats remain professional, safe, and productive. While task-oriented chats typically involve fewer participants than livestreams, maintaining conversation quality is crucial for successful task completion and keeping your users safe.
233+
234+
Ably supports [moderating messages](/docs/chat/moderation) both before and after publication, making it easy to integrate with AI-powered or human moderation systems.
235+
236+
* **After-publish moderation:** Messages appear instantly, then are removed if flagged as inappropriate. Best for most task-oriented scenarios where immediacy matters.
237+
* **Before-publish moderation:** Messages are held until approved. Use this for high-stakes tasks where every message must be vetted.
238+
239+
### Key moderation considerations for task-oriented chat
240+
241+
1. **Platform standards**
242+
* What level of moderation is appropriate for your audience?
243+
* How will you handle different types of content? For example:
244+
* **Hate speech and harassment:** Detecting discriminatory language, threats, or targeted abuse.
245+
* **Discrimination:** Detecting discriminatory language, threats, or targeted abuse.
246+
* **Inappropriate content:** Flagging adult content, violence, or graphic material.
247+
* **Toxicity:** Measuring overall message sentiment and hostility
248+
249+
250+
2. **Technical integration**
251+
* **Latency impact:** AI moderation adds up to 100ms to message delivery.
252+
* **Integration options:** Choose from pre-built integrations or connect your existing moderation systems via webhooks, serverless functions, or queues
253+
254+
3. **Task-specific approaches**
255+
* **Customer support:** Protect both customers and agents from abuse and harassment.
256+
* **Gaming:** Prevent harassment while allowing enthusiastic expressions.
257+
* **Marketplace:** Ensure rules are being followed such as detecting if outside-platform contact info is exchanged.
258+
259+
### How Ably enhances task-oriented moderation
260+
261+
Ably's flexible moderation system adapts to your task requirements:
262+
263+
* **Per-room policies:** Different moderation rules for different task types or user roles
264+
* **Fallback handling:** Configure what happens when moderation services are unavailable
265+
* **Custom integration:** Connect your existing moderation infrastructure via webhooks, serverless functions, or message queues
266+
* **Role-based permissions:** Give moderators special capabilities to manage conversations
267+
268+
<Code>
269+
```javascript
270+
import { ErrorCode } from '@ably/chat';
271+
272+
const room = await chatClient.rooms.get('support-ticket-123');
273+
274+
room.messages.send({text: 'Can you help me with my order?'}).then((message) => {
275+
console.log('Message sent:', message);
276+
}).catch((error) => {
277+
if (error.code === ErrorCode.MessageRejectedByModeration) {
278+
console.log('Message rejected by moderation:', error.message);
279+
return;
280+
}
281+
console.error('Message failed to send:', error);
282+
});
283+
```
284+
</Code>
285+
286+
## Room reactions
287+
288+
Room reactions are a great engagement feature for chats that accompany calls, meetings, collaborative tools, and games. They are a way to quickly express a sentiment to the entire room at a point in time without adding to chat history or being tired to a message.
289+
290+
<Code>
291+
```javascript
292+
// Subscribe to room reactions
293+
room.reactions.subscribe((event) => {
294+
console.log('Room reaction received:', event.reaction.name, "from", event.reaction.clientId);
295+
});
296+
297+
// Send a room reaction
298+
await room.reactions.send({name: '👍'});
299+
```
300+
</Code>
301+
290302
## Handling network disruption
291303

292304
Network disruption happens - mobile internet loses signal or someone drives through a tunnel. All of Ably's SDKs are designed with this in mind, so that you don't have to handle complicated reconnection logic.
@@ -348,18 +360,6 @@ Ably Pub/Sub channels can be used for push notifications. See the [Push notifica
348360

349361
You can also use a separate channel to control notifications, in which case you can tailor them to individual users. Read more about push notifications with Ably in the [Push notifications](/docs/push/publish) documentation.
350362

351-
## Enriching tasks with Ably's realtime services
352-
353-
Ably's comprehensive platform enables you to combine chat with other realtime features to create rich, interactive task experiences.
354-
355-
**Pub/Sub channels** add interactive elements:
356-
- **Live polls:** Quick feedback during collaborative decisions
357-
- **Status updates:** Real-time progress indicators for tasks
358-
- **Interactive ratings:** Instant feedback collection
359-
- **Live auctions:** Real-time bidding in marketplace scenarios
360-
361-
These combined services transform basic chat into comprehensive task management platforms, where communication, coordination, and real-time updates work together seamlessly.
362-
363363
## Production-ready checklist
364364

365365
Before you go live with your task-oriented chat, review these key points:

0 commit comments

Comments
 (0)