claudius-chat-widget
    Preparing search index...

    Interface ClaudiusPlugin

    A client-side middleware that runs around the chat message lifecycle. Pass an array of plugins to ChatWidget via the plugins prop; hooks run in array order.

    Hooks may be async, and may modify, replace, or short-circuit messages. A hook that throws is caught and logged — a misbehaving plugin will not break the chat — so security-sensitive transforms (e.g. PII redaction) should be written defensively.

    const logger: ClaudiusPlugin = {
    name: "logger",
    onBeforeSend: (message) => { console.log("sending", message.content); },
    onAfterReceive: (message) => { console.log("received", message.content); },
    };
    interface ClaudiusPlugin {
        name: string;
        onAfterReceive?(
            message: ChatMessage,
            ctx: PluginContext,
        ): MaybePromise<void | ChatMessage>;
        onBeforeSend?(
            message: ChatMessage,
            ctx: BeforeSendContext,
        ): MaybePromise<void | ChatMessage>;
        onError?(error: Error, ctx: ErrorContext): MaybePromise<void>;
    }
    Index

    Properties

    name: string

    Stable identifier, used in log messages.

    Methods