@salesforce/agents
    Preparing search index...

    Class AgentPreview

    A service to interact with an agent. Start an interactive session, send messages to the agent, and end the session.

    Examples

    Create an instance of the service:

    const agentPreview = new AgentPreview(connection, botId);

    Start an interactive session:

    const { sessionId } = await agentPreview.start();

    Send a message to the agent using the session ID from the startResponse:

    const sendResponse = await agentPreview.send(sessionId, message);

    End an interactive session:

    await agentPreview.end(sessionId, 'UserRequest');

    Enable Apex Debug Mode:

    agentPreview.toggleApexDebugMode(true);

    Index

    Constructors

    • Create an instance of the service.

      Parameters

      • connection: Connection

        The connection to use to make requests.

      • botId: string

        The ID of the agent (Bot ID).

      Returns AgentPreview

    Methods

    • Send a message to the agent using the session ID obtained by calling start().

      Parameters

      • sessionId: string

        A session ID provided by first calling agentPreview.start().

      • message: string

        A message to send to the agent.

      Returns Promise<AgentPreviewSendResponse>

      AgentPreviewSendResponse

    • Enable or disable Apex Debug Mode, which will enable trace flags for the Bot user and create apex debug logs for use within VS Code's Apex Replay Debugger.

      Parameters

      • enable: boolean

        Whether to enable or disable Apex Debug Mode.

      Returns void