Skip to main content

Overview

The Akapulu React SDK exposes a normalized conversation event stream through useAkapuluEvents(...). This hook lets you react to conversation lifecycle changes, transcript updates, tool events, node changes, bot speaking state, and timeout events.

Event handling

Use useAkapuluEvents(listener) anywhere under AkapuluProvider.
import { useAkapuluEvents } from "@akapulu/react";

function EventLogger() {
  useAkapuluEvents((event) => {
    if (event.type === "tool_event") {
      console.log(event.tool.functionName);
      return;
    }

    if (event.type === "transcript_updated") {
      console.log(event.transcript.text);
    }
  });

  return null;
}

Hook signature

useAkapuluEvents(listener: (event: AkapuluEvent) => void): void
listener
(event: AkapuluEvent) => void
required
Listener invoked whenever the Akapulu session store emits a normalized event.

Main unions

SessionStatus

type SessionStatus =
  | "idle"
  | "connecting"
  | "connected"
  | "disconnecting"
  | "ended"
  | "error";

BotSpeakingState

type BotSpeakingState = "idle" | "speaking" | "listening";

ToolMessageType

type ToolMessageType = "RAG" | "vision" | "http";

TimeoutReason

type TimeoutReason = "duration_limit_reached" | "participant_join_timeout";

Event types

status_changed

type
"status_changed"
Event discriminator.
status
"idle" | "connecting" | "connected" | "disconnecting" | "ended" | "error"
Current high-level session lifecycle state.

bot_speaking_state_changed

type
"bot_speaking_state_changed"
Event discriminator.
speakingState
"idle" | "speaking" | "listening"
Current speaking or listening state for the bot participant.

node_changed

type
"node_changed"
Event discriminator.
node
{ key: string; label: string } | null
Current scenario node, or null if no node is active.

tool_event

type
"tool_event"
Event discriminator.
tool
NormalizedToolEvent
Normalized tool event payload.

transcript_updated

type
"transcript_updated"
Event discriminator.
transcript
TranscriptEntry
Transcript row payload.

call_ready

type
"call_ready"
Event discriminator indicating the call reached ready state.

timeout

type
"timeout"
Event discriminator.
reason
"duration_limit_reached" | "participant_join_timeout"
Timeout reason reported by the backend.