You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pages/docs/guides/chat/build-task-oriented.mdx
+60-30Lines changed: 60 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,9 +40,9 @@ For large-scale chat scenarios with many users per room, see our [building lives
40
40
41
41
**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:
42
42
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.
46
46
47
47
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.
48
48
@@ -78,7 +78,7 @@ const header = {
78
78
}
79
79
constcurrentTime=Math.round(Date.now() /1000);
80
80
81
-
// The clientID could be the users ID in your application,
81
+
// The clientId could be the users ID in your application,
82
82
// or a random string if you want to make users anonymous.
83
83
//
84
84
// The capabilities here allow the holder of this token to publish and subscribe to messages,
@@ -103,11 +103,11 @@ console.log('JWT is: ' + ablyJwt);
103
103
104
104
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.
105
105
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.
107
107
108
-
## Presence: Know who's available for your task
108
+
## Presence: Know who's available in the room
109
109
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:
111
111
112
112
***Support tickets:** See when agents are online and available to help.
113
113
***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:
122
122
123
123
This contextual presence information helps participants understand not just who's online, but who's ready and able to engage with the current task.
console.log(`${event.member.clientId} entered with data: ${event.member.data}`);
129
+
130
+
constpresentMembers=awaitroom.presence.get();
131
+
console.log('Present members:', presentMembers);
132
+
});
133
+
134
+
// join presence
135
+
awaitroom.presence.enter({ status:'available' });
136
+
137
+
// change presence data
138
+
awaitroom.presence.enter({ status:'busy' });
139
+
140
+
// leave presence
141
+
awaitroom.presence.leave();
142
+
```
143
+
125
144
## Typing indicators
126
145
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:
128
147
129
148
***Manage expectations:** Users know when a response is being prepared.
130
149
***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
171
190
172
191
Message history is crucial for task-oriented chats, ensuring continuity and context even when participants join mid-task or return after interruptions.
173
192
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.
175
194
195
+
Message history provides users with:
176
196
***Task continuity:** New participants can quickly understand the current state and previous decisions.
177
197
***Context preservation:** Users returning to a task don't lose important information.
178
198
***Audit trail:** Complete conversation records for compliance, training, or dispute resolution.
-**Live auctions:** Real-time bidding in marketplace scenarios.
217
247
218
248
These combined services transform basic chat into comprehensive task management platforms, where communication, coordination, and real-time updates work together seamlessly.
219
249
@@ -235,11 +265,11 @@ Best for most task-oriented scenarios, where immediacy often matters. It can be
235
265
***Hate speech and harassment:** Detecting discriminatory language, threats, or targeted abuse.
236
266
***Discrimination:** Detecting discriminatory language, threats, or targeted abuse.
237
267
***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.
239
269
240
270
2.**Technical integration**
241
271
***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.
243
273
244
274
3.**Task-specific approaches**
245
275
***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
279
309
280
310
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:
0 commit comments