@salesforce/agents
    Preparing search index...

    Class Agent

    A client side representation of an agent within an org. Also provides utilities such as creating agents, listing agents, and creating agent specs.

    Examples

    Create a new instance and get the ID (uses the Bot ID):

    const id = new Agent({connection, name}).getId();

    Create a new agent in the org:

    const myAgent = await Agent.create(connection, project, options);

    List all agents in the local project:

    const agentList = await Agent.list(project);

    Index

    Constructors

    • Create an instance of an agent in an org. Must provide a connection to an org and the agent (Bot) API name or ID as part of AgentOptions.

      Parameters

      Returns Agent

    Methods

    • Activates the agent.

      Returns Promise<void>

      void

    • Deactivates the agent.

      Returns Promise<void>

      void

    • Returns the ID for this agent.

      Returns Promise<string>

      The ID of the agent (The Bot ID).

    • Beta

      Compiles AgentScript returning agent JSON when successful, otherwise the compile errors are returned.

      Parameters

      • connection: Connection

        The connection to the org

      • agentScriptContent: string

        The AgentScriptContent to compile

      Returns Promise<CompileAgentScriptResponse>

      Promise The raw API response

    • Creates an agent from a configuration, optionally saving the agent in an org.

      Parameters

      • connection: Connection

        a Connection to an org.

      • project: SfProject

        a SfProject for a local DX project.

      • config: AgentCreateConfig

        a configuration for creating or previewing an agent.

      Returns Promise<AgentCreateResponse>

      the agent definition

    • Beta

      Creates an AiAuthoringBundle directory, .script file, and -meta.xml file

      Parameters

      • options: {
            agentSpec?: ExtendedAgentJobSpec;
            bundleApiName: string;
            connection: Connection;
            outputDir?: string;
            project: SfProject;
        }

        { connection: Connection; project: SfProject; bundleApiName: string; outputDir?: string; agentSpec?: ExtendedAgentJobSpec; }

      Returns Promise<void>

      Promise

    • List all agents in the current project.

      Parameters

      • project: SfProject

        a SfProject for a local DX project.

      Returns Promise<string[]>

    • Lists all agents in the org.

      Parameters

      • connection: Connection

        a Connection to an org.

      Returns Promise<BotMetadata[]>

      the list of agents

    • Beta

      Publish an AgentJson representation to the org

      Parameters

      • connection: Connection

        The connection to the org

      • project: SfProject

        The Salesforce project

      • agentJson: AgentJson

        The agent JSON with name

      Returns Promise<PublishAgent>

      The publish response