@atlaskit/rovo-triggers

中文文档
12.13.1发布于 2026/11/06Apache-2.0TypeScriptESM + CJS近 30 天下载 6.2万

Provides various trigger events to drive Rovo Chat functionality, such as a publish-subscribe and URL parameter hooks

原始使用文档
文档目录9 节
  1. Example usage
  2. Publish
  3. Subscribe
  4. Subscribe All
  5. Conditionally run subscriptions
  6. Registering new events
  7. Topics
  8. EventTypes
  9. Params utility

Rovo Triggers

(formerly conversation-assistant-pubsub)

Provides various trigger events to drive Rovo Chat functionality, such as a publish-subscribe and URL parameter hooks

Example usage

Publish

import { usePublish } from "@atlaskit/rovo-triggers";

const YourComponent = () => {
    const publish = usePublish('ai-mate');

    const handleClick = () => {
        publish({
            type: "message-send",
            data: "hello Rovo Chat",
            source: "my-source", // source is used for analytics
        })
    }

    return (
        <div>
            <button onClick={handleClick}>
                Send message onbehalf of user in Rovo Chat
            </button>
        </div>
    );
}

Subscribe

import { useSubscribe } from "@atlaskit/rovo-triggers";

const YourComponent = () => {
    const [message, setMessage] = useState('Waiting for messages...');

    useSubscribe({ topic: 'ai-mate' }, ({ type, data }) => {
        if(type === 'message-received') {
            setMessage(data)
        }
    });

    return (<div>{message}</div>);
}

Subscribe (TriggerLatest)

import { useSubscribe } from "@atlaskit/rovo-triggers";

const YourComponent = () => {
    const [message, setMessage] = useState('Waiting for messages...');

    // This subscription will trigger immediately if an event has already been published to the 'ai-mate' topic
    useSubscribe({ topic: 'ai-mate', triggerLatest: true }, ({ type, data, source }) => {
        if(type === 'message-received') {
            setMessage(data)
        }
    });

    return (<div>{message}</div>);
}

Consume once

Publishers can mark an event as consumeOnce: true when only one mounted instance of a consumer should process that event. Subscribers opt into this behavior with a stable consumeOnceKey; subscribers sharing the same key will process a consumeOnce event once total. Subscribers without a consumeOnceKey continue to observe the event normally.

The delivery id used to deduplicate a publish is generated internally by rovo-triggers and is not exposed in the event payload. This deduplicates one publish fanout across multiple mounted subscribers; separate publish calls are treated as separate events.

const YourComponent = () => {
    useSubscribe({ topic: 'ai-mate', consumeOnceKey: 'your-consumer' }, ({ type, data }) => {
        if(type === 'message-send') {
            sendMessage(data)
        }
    });
}
const AnotherComponent = () => {
    const publish = usePublish('ai-mate');

    const handleClick = () => {
        publish({
            type: 'message-send',
            source: 'my-source',
            consumeOnce: true,
            data: { prompt: 'hello Rovo Chat' },
        })
    }
}

Subscribe All

Note - Avoid using this. Right now it's only intended to be a proxy for Rovo Chat to trigger open when new events are published, if it isn't already open.

import { useSubscribeAll } from "@atlaskit/rovo-triggers";

const YourComponent = () => {
    useSubscribeAll(() => {
        console.log('pubsub received an event')
        // do something like open the Rovo Chat panel
    });
  });
}

Conditionally run subscriptions

You can conditionally call a subscription that uses triggerLatest by conditionally rendering the <Subscriber /> component. This can be useful to ensure your state is in the optimal place before triggering it's the subscription (e.g no longer loading)

const YourComponent = ({ startSubscription }: { startSubscription: boolean }) => startSubscription ? (
        <Subscriber
          topic={topic}
          triggerLatest={true}
          onEvent={({ type, data }) => {
            if (type === 'message-send') {
              setMsg(`${data} received at ${new Date().toLocaleTimeString()}`);
              setCount(count + 1);
            }
          }}
        />
      ) : null

Registering new events

Events are a combination of a topic and an event type. As such you can register a new event type by either:

  • Creating a new Topic, and leveraging the existing EventTypes
  • Creating a new Topic, and also creating some new EventTypes to be used
  • Creating another EventType to be used against an existing Topic

This may change as the utility and typings evolve when continuing to build integrations with this package.

Topics

The ai-mate topic is reserved for conversation-assistant events and is the only one that currently exists. Watch this space.

EventTypes

Event types represent actions that have taken place in Rovo Chat, or actions you'd like to trigger within Rovo Chat. As long as there's a registered publish event to the ai-mate topic, you can subscribe to it.

This will be documented as integrations are developed.

Params utility

Rovo Chat uses a strongly typed set of query params encoded to rovoChat which can be used consistently across products.

These values can be used to trigger state changes, routing, actions, for example.

  • clearPageRovoParams - Removes rovoChat param and it’s value from the address bar.

  • updatePageRovoParams - Easily add properties to the rovoChat param in the address bar; this is helpful to continually update the URL for bookmarking or sharing. This method uses addRovoParamsToUrl under the hood.

  • addRovoParamsToUrl - The previous function uses this under the hood, but you can call it directly to add them to an arbitrary URL string, so let’s say you want to redirect from embedded panel to Atlas and do a certain thing, you can call this and pass all the required data to ensure its’ picked up and triggers the right thing on Atlas

  • getRovoParams - The main method you’d use to execute on the values in the rovo params, so you can do Atlas page routing, or trigger actions in the embedded experience (differentiated by UIConfig.fullScreen=false)

Here are some examples of how you might use getRovoParams resulting value:

  • Open new chat { pathway: 'chat' }
  • Open specific chat { pathway: 'chat', conversationId: '123' }
  • Open new chat with specific agent { pathway: 'chat', agentId: '456' }
  • Open specific chat with specific agent { pathway: 'chat', conversationId: '123', agentId: '456' }
  • Open new chat and send message { pathway: 'chat', prompt: 'What should I work on next?' }
  • Open specific chat and send message { pathway: 'chat', conversationId: '123', prompt: 'What should I work on next?' }
  • Open a chat with Rovo journey attribution { pathway: 'chat', rovoJourneyId: '00000000-0000-4000-8000-000000000001' }
  • Open specific chat with specific agent and send message { pathway: 'chat', conversationId: '123', agentId: '456', prompt: 'What should I work on next?' }
  • Browse agents { pathway: 'agents-browse' }
  • View agent details { pathway: 'agents-browse', agentId: '456' }
  • Open create agent experience { pathway: 'agents-create' }

版本与发布记录

@atlaskit/rovo-triggers 共发布 243 个版本,首次发布于 2024/10/18;过去 12 个月发布了 182 个版本。

版本发布日期距今
12.13.1latest2026/11/061 天前
12.13.02026/11/052 天前
12.12.02026/10/317 天前
12.11.02026/10/2810 天前
12.10.02026/10/2810 天前
12.9.02026/10/2711 天前

关于 @atlaskit/rovo-triggers 的常见问题

@atlaskit/rovo-triggers 是什么?

Provides various trigger events to drive Rovo Chat functionality, such as a publish-subscribe and URL parameter hooks

如何安装 @atlaskit/rovo-triggers?

在项目目录运行 npm install @atlaskit/rovo-triggers,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@atlaskit/rovo-triggers 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@atlaskit/rovo-triggers 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@atlaskit/rovo-triggers 可以商用吗?

@atlaskit/rovo-triggers 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@atlaskit/rovo-triggers 的下载量有多少?

根据 npm 官方下载统计,@atlaskit/rovo-triggers 在 2026/10/07 – 2026/11/05 这 30 天内被下载 62,310 次,日均约 2,077 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@atlaskit/rovo-triggers 还在维护吗?

最新版本 12.13.1 发布于 2026/11/06(1 天前);至今共发布 243 个版本,其中过去 12 个月发布了 182 个;首次发布于 2024/10/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。