Skip to content

Commit fcb7b39

Browse files
committed
fixes based on reivew comments
1 parent 9357624 commit fcb7b39

File tree

1 file changed

+60
-30
lines changed

1 file changed

+60
-30
lines changed

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

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ For large-scale chat scenarios with many users per room, see our [building lives
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

43-
* **Automatically scaled** - Ably handles any number of concurrent rooms without provisioning
44-
* **History-enabled** - messages stored for 30 days by default (configurable up to a year on request)
45-
* **Kept under control** - [capabilites](/docs/chat/setup#authentication) let you control who can join and the level of access to features and actions
43+
* **Automatically scaled** - Ably handles any number of concurrent rooms without provisioning.
44+
* **History-enabled** - messages stored for 30 days by default (configurable up to a year on request).
45+
* **Kept under control** - [capabilites](/docs/chat/setup#authentication) let you control who can join and the level of access to features and actions.
4646

4747
Each room includes all task participants: customers and agents in support, buyers and sellers in marketplaces, players in games, team members in projects. Participants can join and leave as the task evolves. Access to message history and other features can be granted to all or select participants via capabilities.
4848

@@ -78,7 +78,7 @@ const header = {
7878
}
7979
const currentTime = Math.round(Date.now() / 1000);
8080

81-
// The clientID could be the users ID in your application,
81+
// The clientId could be the users ID in your application,
8282
// or a random string if you want to make users anonymous.
8383
//
8484
// The capabilities here allow the holder of this token to publish and subscribe to messages,
@@ -103,11 +103,11 @@ console.log('JWT is: ' + ablyJwt);
103103

104104
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.
105105

106-
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.
106+
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.
107107

108-
## Presence: Know who's available for your task
108+
## Presence: Know who's available in the room
109109

110-
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:
110+
[Presence](/docs/chat/rooms/presence) shows you who's currently active in the room. This is especially valuable for scenarios where task completion depends on participant availability:
111111

112112
* **Support tickets:** See when agents are online and available to help.
113113
* **Deliveries:** Know if the delivery driver or customer is actively monitoring the chat.
@@ -122,9 +122,28 @@ Beyond just online/offline status, presence can include rich information:
122122

123123
This contextual presence information helps participants understand not just who's online, but who's ready and able to engage with the current task.
124124

125+
```javascript
126+
// subscribe to presence events
127+
const { unsubscribe } = room.presence.subscribe((event) => {
128+
console.log(`${event.member.clientId} entered with data: ${event.member.data}`);
129+
130+
const presentMembers = await room.presence.get();
131+
console.log('Present members:', presentMembers);
132+
});
133+
134+
// join presence
135+
await room.presence.enter({ status: 'available' });
136+
137+
// change presence data
138+
await room.presence.enter({ status: 'busy' });
139+
140+
// leave presence
141+
await room.presence.leave();
142+
```
143+
125144
## Typing indicators
126145

127-
Typing indicators are now a common feature in most chat applications. They show when someone is actively composing a message, helping to:
146+
[Typing indicators](/docs/chat/rooms/typing) are a common feature in most chat applications. They show when someone is actively composing a message, helping to:
128147

129148
* **Manage expectations:** Users know when a response is being prepared.
130149
* **Reduce duplicate messages:** See that someone is already addressing the question.
@@ -171,8 +190,9 @@ Message reactions in Ably Chat come in three types: `unique`, `distinct` and `mu
171190

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

174-
Ably stores [chat history](/docs/chat/rooms/history) for 30 days by default, with options to extend up to a year.
193+
Ably stores [chat history](/docs/chat/rooms/history) for 30 days by default, with options to extend up to a year on request.
175194

195+
Message history provides users with:
176196
* **Task continuity:** New participants can quickly understand the current state and previous decisions.
177197
* **Context preservation:** Users returning to a task don't lose important information.
178198
* **Audit trail:** Complete conversation records for compliance, training, or dispute resolution.
@@ -197,7 +217,17 @@ const subscription = room.messages.subscribe((messageEvent) => {
197217

198218
// Load recent history for context
199219
// This ensures you get a complete picture without missing messages
200-
await subscription.historyBeforeSubscription({limit: 50});
220+
let historyResponse = await subscription.historyBeforeSubscription({limit: 50});
221+
222+
// Itarate through all pages
223+
while (true) {
224+
console.log('Messages: ', historyResponse.items);
225+
if (historyResponse.hasNext()) {
226+
historyResponse = await historyResponse.next();
227+
} else {
228+
break;
229+
}
230+
}
201231
```
202232
</Code>
203233

@@ -210,10 +240,10 @@ See the [React UI Kit](/docs/chat/react-ui-kit) for more details.
210240
Ably's comprehensive platform enables you to combine chat with other realtime features to create rich, interactive task experiences.
211241

212242
**Pub/Sub channels** add interactive elements:
213-
- **Live polls:** Quick feedback during collaborative decisions
214-
- **Status updates:** Real-time progress indicators for tasks
215-
- **Interactive ratings:** Instant feedback collection
216-
- **Live auctions:** Real-time bidding in marketplace scenarios
243+
- **Live polls:** Quick feedback during collaborative decisions.
244+
- **Status updates:** Real-time progress indicators for tasks.
245+
- **Interactive ratings:** Instant feedback collection.
246+
- **Live auctions:** Real-time bidding in marketplace scenarios.
217247

218248
These combined services transform basic chat into comprehensive task management platforms, where communication, coordination, and real-time updates work together seamlessly.
219249

@@ -235,11 +265,11 @@ Best for most task-oriented scenarios, where immediacy often matters. It can be
235265
* **Hate speech and harassment:** Detecting discriminatory language, threats, or targeted abuse.
236266
* **Discrimination:** Detecting discriminatory language, threats, or targeted abuse.
237267
* **Inappropriate content:** Flagging adult content, violence, or graphic material.
238-
* **Toxicity:** Measuring overall message sentiment and hostility
268+
* **Toxicity:** Measuring overall message sentiment and hostility.
239269

240270
2. **Technical integration**
241271
* **Latency impact:** AI moderation adds up to 100ms to message delivery.
242-
* **Integration options:** Choose from pre-built integrations or connect your existing moderation systems via webhooks, serverless functions, or queues
272+
* **Integration options:** Choose from pre-built integrations or connect your existing moderation systems via webhooks, serverless functions, or queues.
243273

244274
3. **Task-specific approaches**
245275
* **Customer support:** Protect both customers and agents from abuse and harassment.
@@ -279,15 +309,15 @@ AI chatbots are revolutionizing the way we interact with digital platforms. Inte
279309

280310
Ably's flexible [integration capabilities](/docs/platform/integrations) make it easy to connect your chat system with AI services. Through Ably's integrations, you can automatically route messages to:
281311

282-
* Serverless functions (AWS Lambda, Azure Functions, etc.),
283-
* Event streaming services including Kafka, SQS and Pulsar,
312+
* Serverless functions (AWS Lambda, Azure Functions, and others).
313+
* Event streaming services including Kafka, SQS and Pulsar.
284314
* Webhooks and custom endpoints.
285315

286316
This enables powerful AI features like:
287317

288-
* Sentiment analysis of chat messages,
289-
* AI-powered responses to common questions and support queries,
290-
* Chat summarization and key point extraction,
318+
* Sentiment analysis of chat messages.
319+
* AI-powered responses to common questions and support queries.
320+
* Chat summarization and key point extraction.
291321
* Automatically adding contextual information for your agents to help them be more effective.
292322

293323
For example, you could set up an integration that sends all messages from each chat room to an AI service for sentiment analysis,
@@ -333,20 +363,20 @@ Task-oriented chats are typically short-lived but can be numerous, making effici
333363

334364
**Consumption-based pricing** is ideal for most task-oriented scenarios:
335365

336-
* **Pay per message/minute:** Only pay for actual engagement, perfect for sporadic task conversations
337-
* **Volume discounts:** Lower rates as your usage scales across all your tasks
338-
* **No user-based fees:** You're not charged for users who join briefly or tasks that end quickly
366+
* **Pay per message/minute:** Only pay for actual engagement, perfect for sporadic task conversations.
367+
* **Volume discounts:** Lower rates as your usage scales across all your tasks.
368+
* **No user-based fees:** You're not charged for users who join briefly or tasks that end quickly.
339369

340370
**MAU-based pricing** works well when you have:
341371

342-
* **Consistent task volume:** Regular support tickets, frequent deliveries, or ongoing collaborative work
343-
* **Predictable user engagement:** Teams or customers who regularly participate in tasks
344-
* **Longer-term task relationships:** Ongoing gaming communities or service subscriptions
372+
* **Consistent task volume:** Regular support tickets, frequent deliveries, or ongoing collaborative work.
373+
* **Predictable user engagement:** Teams or customers who regularly participate in tasks.
374+
* **Longer-term task relationships:** Ongoing gaming communities or service subscriptions.
345375

346376
For example:
347-
- **Support platforms:** Often benefit from consumption pricing due to variable ticket volume
348-
- **Delivery services:** MAU pricing if you have consistent delivery personnel and customers
349-
- **Gaming platforms:** Consumption pricing for casual games, MAU for subscription-based gaming
377+
- **Support platforms:** Often benefit from consumption pricing due to variable ticket volume.
378+
- **Delivery services:** MAU pricing if you have consistent delivery personnel and customers.
379+
- **Gaming platforms:** Consumption pricing for casual games, MAU for subscription-based gaming.
350380

351381
A full breakdown of pricing options can be found on the [pricing page](/pricing).
352382

0 commit comments

Comments
 (0)