Javascript API Reference
    Preparing search index...

    Type Alias AgentParticipantEvent

    type AgentParticipantEvent = {
        "agent-metrics": (
            data: {
                latency: object;
                providers?: object;
                speech: object;
                systemInstructions?: object;
            },
        ) => void;
        "agent-state-changed": (data: { state: string }) => void;
        "agent-transcription-received": (
            data: {
                participant: Participant | AgentParticipant;
                segment: { text: string; timestamp: number; type?: string };
            },
        ) => void;
        "media-status-changed": (data: { kind: string; newStatus: string }) => void;
        "stream-disabled": (stream: Stream) => void;
        "stream-enabled": (stream: Stream) => void;
    }
    Index

    Events

    "agent-metrics": (
        data: {
            latency: object;
            providers?: object;
            speech: object;
            systemInstructions?: object;
        },
    ) => void

    Triggered after each conversational turn with metrics and speech data.

    Type Declaration

      • (
            data: {
                latency: object;
                providers?: object;
                speech: object;
                systemInstructions?: object;
            },
        ): void
      • Parameters

        • data: {
              latency: object;
              providers?: object;
              speech: object;
              systemInstructions?: object;
          }
          • latency: object

            This represents the latency metrics for the current turn.

          • Optionalproviders?: object

            This represents the providers used (e.g., TTS, STT, LLMs). This is available only in the first turn.

          • speech: object

            This represents the user and agent speech for the current turn.

          • OptionalsystemInstructions?: object

            This represents the system instructions configured for the agent. This is available only in the first turn.

        Returns void

    agentParticipant?.on("agent-metrics", (data) => {
    const { latency, speech, providers, systemInstructions } = data;

    console.log("Latency:", latency);
    console.log("Speech:", speech);
    });
    "agent-state-changed": (data: { state: string }) => void

    Triggered when the state of the agentParticipant changes.

    Type Declaration

      • (data: { state: string }): void
      • Parameters

        • data: { state: string }
          • state: string

            This represents the current state of the agentParticipant.

            Possible values: AgentState

        Returns void

    agentParticipant?.on("agent-state-changed", (data) => {
    const { state } = data;

    if (state === VideoSDK.Constants.AgentState.SPEAKING) {
    console.log("Agent is speaking...");
    }

    });
    "agent-transcription-received": (
        data: {
            participant: Participant | AgentParticipant;
            segment: { text: string; timestamp: number; type?: string };
        },
    ) => void

    Triggered when a transcription is received from a participant or agent.

    Type Declaration

      • (
            data: {
                participant: Participant | AgentParticipant;
                segment: { text: string; timestamp: number; type?: string };
            },
        ): void
      • Parameters

        • data: {
              participant: Participant | AgentParticipant;
              segment: { text: string; timestamp: number; type?: string };
          }
          • participant: Participant | AgentParticipant

            This represents the participant whose speech is transcribed. It can be either an AgentParticipant or a regular Participant, depending on who is speaking.

          • segment: { text: string; timestamp: number; type?: string }

            This represents the transcription segment.

            • text: string

              This represents the transcribed text.

            • timestamp: number

              This represents the timestamp of the transcription.

            • Optionaltype?: string

              This represents the type of the transcription segment (e.g., "final", "intrim").

        Returns void

    agentParticipant?.on("agent-transcription-received", (data) => {
    const { segment, participant } = data;
    const { text, timestamp } = segment;

    console.log(`${participant.displayName} said "${text}" at ${timestamp}`);
    });
    "media-status-changed": (data: { kind: string; newStatus: string }) => void

    Triggered when the media status of a participant changes (for example, when audio or video is enabled or disabled).

    Type Declaration

      • (data: { kind: string; newStatus: string }): void
      • Parameters

        • data: { kind: string; newStatus: string }
          • kind: string

            Type of stream whose status changed.

          • newStatus: string

            The updated status of the stream.

        Returns void

    agentParticipant.on("media-status-changed", (data) => {
    const { kind, newStatus } = data;
    });
    "stream-disabled": (stream: Stream) => void

    Triggered when a participant’s audio, video, or screen-share Stream is disabled.

    Type Declaration

      • (stream: Stream): void
      • Parameters

        • stream: Stream

          The stream that was disabled.

        Returns void

    agentParticipant.on("stream-disabled", (stream) => {
    //
    });
    "stream-enabled": (stream: Stream) => void

    Triggered when a participant’s audio, video, or screen-share Stream is enabled.

    Type Declaration

      • (stream: Stream): void
      • Parameters

        • stream: Stream

          The stream that was enabled.

        Returns void

    agentParticipant.on("stream-enabled", (stream) => {
    //
    });