Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Provides the Ably 2.x JavaScript SDK for realtime pub/sub channels, presence, message history, and token authentication.
82% 95%+14 ptsof test cases passed
Passed 21 of 22 test cases with the skill, and 18 of 22 without it.
I want to implement real-time messaging into our web application using Ably's specialized chat package. Could you write a TypeScript code snippet demonstrating how to initialize a chat room, send text messages, broadcast user typing indicators, and handle message reactions?
Initializes ChatClient directly with the realtime client instance via new ChatClient(realtimeClient)
This test ran on v1. v2 is the current version and hasn’t been tested on gemini-3.6-flash yet.
3 of 3 safety checks passed
Ably is a managed pub/sub platform. An application publishes messages to named channels and every subscribed client receives them over a WebSocket connection that the SDK keeps alive and resumes after a short network drop. On top of plain messaging it provides presence (who is on a channel), message history, token authentication with per-channel permissions, and a separate Chat SDK with rooms, typing indicators and reactions.
Two clients exist in the ably package: Ably.Realtime holds a connection and can subscribe; Ably.Rest is stateless HTTP and is the right choice for servers and serverless functions that only publish or issue tokens.
npm install ably
npm install @ably/chat # Chat SDK, optional; built on top of ably
npm install jsonwebtoken # server side, to sign tokens for browser clients
Create an app in the Ably dashboard and copy an API key. A key looks like I2E_JQ.OqUdfg:EVKVT...: the part before the colon is the key name, the part after it is the secret. Keep it in ABLY_API_KEY on the server only.
Browsers and mobile apps must never receive the API key. The server signs a short-lived JWT with the key secret; the SDK fetches it through authUrl (or authCallback) and renews it before it expires.
// server/ably-token.ts
import jwt from "jsonwebtoken";
const [keyName, keySecret] = process.env.ABLY_API_KEY!.split(":");
export function createAblyToken(userId: string): string {
return jwt.sign(
{
"x-ably-clientId": userId,
// capability is a JSON string: resource -> allowed operations
"x-ably-capability": JSON.stringify({
"orders:*": ["subscribe", "history"],
[`notifications:${userId}`]: ["subscribe"],
"support:*": ["publish", "subscribe", "presence", "history", "message-update-own"],
}),
Next to this one in the catalogue, plus more from the same author.