Important to note: A known Salesforce bug will cause deployments to fail if a Prompt Template is linked to a Flow that contains an Apex action. To work around this, you must deploy the Flow and Apex components first, then deploy the Prompt Template in a separate package.
Gearset's Agentforce metadata deployment solution simplifies and streamlines the process of deploying AI-powered configurations, including Prompt Templates, in Salesforce. Agentforce Prompt Templates are a key component in creating AI Agents. They are a set of instructions that guide AI Agents to generate responses to user queries.
This guide will explain how to successfully deploy the Prompt Template metadata with Gearset.
Prerequisites
Make sure to use at least API version 60 for the comparison. Read the prerequisite section of the How to deploy GenAi metadata guide to find out how to do this.
What metadata is needed in the filter?
If you are only deploying the Prompt template, in your metadata filter you'll only need to include Prompt Template.
If you are also deploying dependencies (like Custom Objects, Apex or Flows) you may want to include their metadata in the filter as well.
How to deploy Prompt Template metadata with Gearset
To be able to deploy the Prompt Template metadata type, you need to make sure that all dependencies exist in the target org. If they don't then you need to deploy them alongside the Prompt Template.
Note: This is not required for VCS targets, however it's strongly recommended to keep your VCS up to date with all required metadata.
Example 1: Dependency added to the <relatedEntity> and <relatedField> xml tags
In this case, the Account custom object with the field AccountNumber would need to be present on the target org. If it's not present then it will need to be deployed alongside the Prompt Template metadata otherwise the validation/deployment will fail.
Example 2: Dependency added to the <content> xml tag
In this case the Apex class PersonalizedGuestExperiences would need to be present on the target org. If it's is not present then it will need to be deployed alongside the Prompt Template metadata.
As you can see from the examples above, the Prompt Template metadata can have dependencies on a large amount of objects. We will be adding more problem analyzers over time to help highlight any missing dependencies before you validate or deploy your Agentforce metadata.
How does Gearset deal with prompt templates that reference org-specific Einstein Search Retriever IDs?
If the prompt template you want to deploy references an org-specific retriever ID, Salesforce might fail the deployment if the reference in the source doesn't exist in the target org.
To help with this, we've introduced a Problem Analyzer that automatically swaps that reference before deployment with the one from the target. This gives the deployment a better chance of succeeding.




