Apex merge fields versus Flow for prompt grounding
Key Takeaway
A prompt template works with a flow or Apex class only when the template's inputs include every input that resource requires. All flow inputs are considered required, but Apex inputs are optional unless they're annotated as required.
Grounding gives the LLM the context it needs to write personalized responses based on your accurate, up-to-date data. Flow and Apex merge fields both bring a resource you build into a prompt template. However, they follow different rules about which inputs the template must supply, so the right choice depends on what inputs your template has.
Grounding a prompt template with merge fields
When you create a prompt template, you first choose the object it's associated with, such as an account or contact. For a field generation template, you also pick the field that Einstein helps users complete.
Prompt Builder grounds prompt templates dynamically with CRM data through merge fields. In the Prompt Template Workspace, you add merge fields with the "Insert Resource" button. A merge field can reference any of these:
- Record fields
- Related lists
- Data 360 DMOs
- Flows
- Apex classes