Sub topic 2
Writing Instructions That Use Grounded Data Well
Assume you know Salesforce objects, relationships, Flow Builder, and the basics of Prompt Builder. Grounding means inserting trusted CRM data into a prompt so the model can answer from the current record instead of guessing.
Write Instructions Around the Grounded Data
Tell the model what each value means and what to do when it is missing. Keep instructions separate from data, and specify the required output.
You are a support assistant. Summarize this case in two sentences for the next agent.
Case subject: {!$Input:Case.Subject}
Status: {!$Input:Case.Status}
Priority: {!$Input:Case.Priority}
Description: {!$Input:Case.Description}
If a value is empty, say "Not provided." Do not guess.
Mention the customer's main issue and the next action.The merge fields are resolved before the prompt is sent to the large language model. Explicit missing-value rules reduce invented details. Output rules make responses easier to evaluate and use.
Pull in Related Records
A record merge field can follow a relationship from the template's input record to a related record. For example, a Case can provide Account and Contact values:
Customer account: {!$Input:Case.Account.Name}
Account industry: {!$Input:Case.Account.Industry}
Contact: {!$Input:Case.Contact.Name}This works well for a small, known set of fields. Explain the relationship in the surrounding instruction, and define what happens when the relationship or field is empty. Do not assume every Case has a Contact or Account.
Grounding with a Flow
Use a Flow resource when the prompt needs logic, multiple records, filtering, or formatting. A Flow can receive the template's input record, query related data, format it as text, and return that text to the template.
For example, a Flow named Get_Recent_Orders might return a short order-history block:
Recent order history:
{!$Flow:Get_Recent_Orders.Prompt}Design the Flow to return useful text even when no records match, such as No recent orders found. Limit queried records and fields, then format the result for the model rather than returning raw Salesforce data.
Exercise
When should you use a Flow instead of several relationship merge fields?
Show answer
Use a Flow when you need queries, filtering, multiple related records, conditional logic, or custom formatting.