Overview
Events allow your application to dynamically respond to changes in user context in real time. These events are automatically captured when relevant changes occur. You can subscribe to them by registering event listeners.
Key Considerations
Please note the following:
- Events will only trigger for active connections.
- Events are not captured unless explicitly listened for.
- A single instance of the
eventQueue
is shared across all connections.
Quick Start Guide
- Start listening in the loop with
listenForEvents
.
The functionEventQueue.waitEvent
returns a event when one is captured.
const eventQueue = await EndpointFactory.getEventQueue();
function listenForEvents(eventsQueue) {
eventsQueue.waitEvent().then(event => {
console.log("onEvent", event);
listenForEvents(eventsQueue);
});
}
listenForEvents(eventQueue);
- Subscribe to Tool (e.g. Thread) events:
await threadApi.subscribeForMessageEvents(threadID);
- Unsubscribe, if events no longer needed:
await threadApi.unsubscribeFromMessageEvents(threadID);