Skip to content
// EFFECT DAYS 2026

Chat unstable

The routed outbound chat service.

Chat has the ops of every registered adapter and routes each call by the address's platform. Chat.layer provides the router and an empty ChatAdapter.Registry; adapter layers stack on top with Layer.provideMerge, and a platform that is off is a layer left out.

Example Posting through the router

import { Effect } from "effect"
import { Chat, ChatThread } from "effect/chat"
const program = Effect.gen(function*() {
const chat = yield* Chat.Chat
const posted = yield* chat.post(ChatThread.make("slack", "T1/C1"), { markdown: "Hello" })
return posted.id
})
3 exports Since v4.1.5 Source

Combinators

Since v4.1.5

Runs an effect with adapter retries turned off, so every adapter call inside it makes one attempt.

Gotchas

The name is provisional.

Signature

declare function withoutRetries<A, E, R>(effect: Effect<A, E, R>): Effect<A, E, R>

Layers

layer

unstable
Since v4.1.5

Layer that provides the Chat router and an empty ChatAdapter.Registry.

When to use

Use as the base of a chat setup. Adapter layers go on top with Layer.provideMerge.

Signature

declare const layer: Layer.Layer<Chat | Registry>

Services

Chat

unstable
Since v4.1.5

Service that routes chat operations to the adapter registered for each address's platform.

Details

  • Every op takes an address and goes to the adapter for thread.platform, failing with NoAdapter when there is none.
  • getUser takes the platform first, because a bare user id names none.
  • followUp is routed by the platform of the deferred command's thread. One call per deferral is the portable contract: the first is the answer, and a second is platform-specific, a new message on Slack (up to five) and an overwrite of the first on Discord. It is rendered as respond is, so it never mentions anyone: Slack shows the token as text and Discord renders it and notifies nobody.
  • descriptor returns a platform's capabilities and limits.
  • Each call runs in a Chat.{op} span whose attributes are the platform, the op and, on failure, the error reason and retry value.

Signature

declare class Chat extends Shape<"effect/chat/Chat", Omit<Ops, "getUser"> & {
readonly descriptor: (platform: string) => Effect<Descriptor, ChatError>;
readonly getUser: (platform: string, id: string, options?: {
readonly in?: {
readonly id: string;
readonly platform: string;
};
}) => Effect<User, ChatError>;
}, this> {
constructor(_: never);
}