React Api Reference
    Preparing search index...

    Class useAgentParticipant

    useAgentParticipant provides reactive access to a agentParticipant's state, streams, controls, statistics, and related events within a meeting.

    Index

    Constructors

    Properties

    agentParticipant: AgentParticipant

    This represents the underlying Participant instance.

    displayName: string

    This represents display name of the agentParticipant.

    isActiveSpeaker: boolean

    This represents whether the agentParticipant is the active speaker.

    micOn: boolean

    This represents whether the agentParticipant's microphone is enabled.

    micStream: Stream

    This represents the microphone audio Stream of the agentParticipant.

    mode: "SEND_AND_RECV" | "SIGNALLING_ONLY" | "RECV_ONLY"

    This represents the current mode of the agentParticipant.

    pinState: any

    This represents the current pin state of the agentParticipant.

    webcamOn: boolean

    This represents whether the agentParticipant's webcam is enabled.

    webcamStream: Stream

    This represents the webcam video Stream of the agentParticipant.

    Methods

      • This method can be used to get detailed statistics about the agentParticipant's audio stream.
      • These metrics provide insights into stream quality, network conditions, and transmission performance at the time the method is called.

      Returns Promise<
          {
              bitrate: number;
              codec: string;
              jitter: number;
              network: string;
              packetsLost: number;
              rtt: number;
              totalPackets: number;
          }[],
      >

      An array of objects containing the following metrics:

      • jitter – Represents variation in packet arrival time (stream instability).
      • bitrate – The bitrate at which the audio stream is being transmitted.
      • totalPackets – Total number of packets transmitted for the stream.
      • packetsLost – Total number of packets lost during transmission.
      • rtt – Round-trip time (in milliseconds) between the client and server.
      • codec – Codec used for encoding the audio stream.
      • network – Network type used for transmitting the stream.

      Info

      If the rtt value exceeds 300ms, consider switching to a region closer to the user for improved performance. Learn more visit here.

      const { getAudioStats } = useAgentParticipant(agentParticipantId);

      const audioStats = await getAudioStats();
      • This method can be used to get detailed statistics about the agentParticipant’s video stream.
      • These metrics provide insights into stream quality, network conditions, and transmission performance at the time the method is called.

      Returns Promise<
          {
              bitrate: number;
              codec: string;
              currentSpatialLayer: number;
              currentTemporalLayer: number;
              jitter: number;
              limitation: any;
              network: string;
              packetsLost: number;
              preferredSpatialLayer: number;
              preferredTemporalLayer: number;
              rtt: number;
              size: any;
              totalPackets: number;
          }[],
      >

      An array of objects containing the following metrics:

      • jitter – Represents variation in packet arrival time (stream instability).
      • bitrate – The bitrate at which the video stream is being transmitted.
      • totalPackets – Total number of packets transmitted for the stream.
      • packetsLost – Total number of packets lost during transmission.
      • rtt – Round-trip time (in milliseconds) between the client and server.
      • codec – Codec used for encoding the video stream.
      • network – Network type used for transmitting the stream.
      • limitation – Indicates any limitations affecting stream quality.
      • size – Resolution or size information related to the stream.

      Info

      If the rtt value exceeds 300ms, consider switching to a region closer to the user for improved performance. Learn more visit here.

      const { getVideoStats } = useAgentParticipant(agentParticipantId);

      const videoStats = await getVideoStats();
      • This method can be used to pin the agentParticipant's camera, screen share, or both.

      • Every participant receives a onPinStateChanged event when the pin state is updated.

      Parameters

      • type: "SHARE_AND_CAM" | "CAM" | "SHARE"

        Specifies which stream to pin.

        Allowed values:

        • "SHARE_AND_CAM" – Pins both screen share and camera streams.
        • "CAM" – Pins only the camera stream.
        • "SHARE" – Pins only the screen-share stream.
        SHARE_AND_CAM
        

      Returns void

      const { pin } = useAgentParticipant(agentParticipantId);

      pin("CAM");
      • This method can be used to removes the remote agentParticipant from the meeting.

      Returns void

      const { remove } = useAgentParticipant(agentParticipantId);

      remove();
      • This method can be used to unpin the agentParticipant's camera, screen share, or both.

      • Every participant receives a onPinStateChanged event when the pin state is updated.

      Parameters

      • type: "SHARE_AND_CAM" | "CAM" | "SHARE"

        Specifies which stream to unpin.

        Allowed values:

        • "SHARE_AND_CAM" – Unpins both screen share and camera streams.
        • "CAM" – Unpins only the camera stream.
        • "SHARE" – Unpins only the screen-share stream.
        "SHARE_AND_CAM"
        

      Returns void

      const { unpin } = useAgentParticipant(agentParticipantId);

      unpin("CAM");

    Events

    • Triggered when the state of the agentParticipant changes.

      Parameters

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

          This represents the current state of the agentParticipant.

          Possible values: AgentState

      Returns void

      onAgentStateChanged(data) {
      const { state } = data;

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

      }

      const {
      displayName
      ...
      } = useAgentParticipant(agentParticipantId,{
      onAgentStateChanged,
      ...
      });
    • Triggered when a transcription is received from a participant or agent.

      Parameters

      • data: { participant: any; segment: { text: string; timestamp: number } }
        • participant: any

          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 }

          This represents the transcription segment.

          • text: string

            This represents the transcribed text.

          • timestamp: number

            This represents the timestamp of the transcription.

      Returns void

      onAgentTranscriptionReceived(data){
      const { segment, participant } = data;
      const { text, timestamp } = segment;

      console.log(`${participant.displayName} said "${text}" at ${timestamp}`);
      }

      const {
      displayName
      ...
      } = useAgentParticipant(agentParticipantId,{
      onAgentTranscriptionReceived,
      ...
      });
    • Triggered when the media status of a agentParticipant changes (for example, when audio or video is enabled or disabled).

      Parameters

      • data: { kind: "audio" | "video" | "share" | "shareAudio"; newStatus: boolean }
        • kind: "audio" | "video" | "share" | "shareAudio"

          Type of stream whose status changed.

        • newStatus: boolean

          The updated status of the stream.

      Returns void

      function onMediaStatusChanged(data) {
      const { kind, newStatus} = data;
      }

      const {
      displayName
      ...
      } = useAgentParticipant(agentParticipantId,{
      onMediaStatusChanged,
      ...
      });
    • Triggered when a agentParticipant’s audio or video stream is disabled.

      Parameters

      • stream: Stream

        The Stream that was disabled.

      Returns void

      function onStreamDisabled(stream) {
      console.log("onStreamDisabled", stream);
      }

      const {
      displayName
      ...
      } = useAgentParticipant(agentParticipantId,{
      onStreamDisabled,
      ...
      });
    • Triggered when a agentParticipant’s audio or video stream is enabled.

      Parameters

      • stream: Stream

        The Stream that was enabled.

      Returns void

      function onStreamEnabled(stream) {
      console.log("onStreamEnabled", stream);
      }

      const {
      displayName
      ...
      } = useAgentParticipant(agentParticipantId,{
      onStreamEnabled,
      ...
      });