Generate an agent template from an existing agent in your DX project so you can then package the template in a second-generation managed package.
Description for agent generate template
WARNING: This command doesn’t work for agents that were created from an Agent Script file. In other words, you can’t currently package an agent template for agents that use Agent Script.
At a high-level, agents are defined by the Bot, BotVersion, and GenAiPlannerBundle metadata types. The GenAiPlannerBundle type in turn defines the agent’s topics and actions. This command uses the metadata files for these three types, located in your local DX project, to generate a BotTemplate metadata file for a specific agent (Bot). You then use the BotTemplate metadata file, along with the GenAiPlannerBundle metadata file that references the BotTemplate, to package the template in a managed package that you can share between orgs or on AppExchange.
Use the –agent-file flag to specify the relative or full pathname of the Bot metadata file, such as force-app/main/default/bots/My_Awesome_Agent/My_Awesome_Agent.bot-meta.xml. A single Bot can have multiple BotVersions, so use the –agent-version flag to specify the version. The corresponding BotVersion metadata file must exist locally. For example, if you specify “–agent-version 4”, then the file force-app/main/default/bots/My_Awesome_Agent/v4.botVersion-meta.xml must exist.
The new BotTemplate metadata file is generated in the “botTemplates” directory in the output directory specified with the –output-dir flag, and has the name <Agent_API_name>_v<Version>_Template.botTemplate-meta.xml, such as my-package/botTemplates/My_Awesome_Agent_v4_Template.botTemplate-meta.xml. The command displays the full pathname of the generated files when it completes.
Override the api version used for api requests made by this command
‑‑flags‑dir
N/A
Type: Value
Import flag values from a directory.
‑‑json
N/A
Type: Boolean
Format output as json.
‑‑output‑dir
‑r
Type: Value
Directory where the generated BotTemplate and GenAiPlannerBundle files are saved.
‑‑source‑org
‑s
Type: Value Required
Username or alias of the namespaced scratch org that contains the agent which this template is based on.
Examples for agent generate template
Generate an agent template from the My_Awesome_Agent Bot metadata file in your DX project and save the BotTemplate and GenAiPlannerBundle to the specified directory; use version 1 of the agent. The agent that the template is based on is in the org with alias “my-scratch-org”: