What’s trending
UPCOMING EVENTS
How to Use Template-Triggered Prompt Flows in Salesforce to Automate AI
By Viktoriya Mishchuk
Salesforce’s Template-Triggered Prompt Flows are a powerful way to bring automation and AI together. They let you generate AI-powered prompts automatically by pulling real-time data from Salesforce records. Instead of writing prompts by hand, Salesforce takes care of it for you by formatting the information into a structured Prompt Template. The result is AI content that’s more relevant, more consistent, and actually useful in context.
What makes this feature especially interesting is that it goes beyond just filling in fields. These flows can run logic, perform actions, and create dynamic output based on what’s actually happening in your org. That output is then merged into the final version of the prompt using the resolution defined in the template. So, rather than just passing record data into a static message, the flow builds meaningful context first and then hands it off to the Prompt Template, and implicitly AI, to complete the task.
How Template-Triggered Prompt Flows Work
At a high level, these flows work in three main stages.
1. Dynamic Logic and Actions
Template-Triggered Prompt Flows don’t just pull in data – they can run logic to create output that’s tailored to the situation. You can add decisions, transform values, or even pull in information from outside sources. The result is a text that reflects the current state of the record and the flow’s logic, not just a copy-paste of field values.
2. Merging With the Prompt Template
Once the flow creates the output, it gets passed into the Prompt Template. The template gives the content structure and clarity and defines how the final prompt should be read. You end up with something that feels complete, consistent, and ready for the AI to understand.
3. Real-Time AI Interaction
Now that the prompt is fully built, it’s sent to the LLM, which responds based on the context and instructions provided. That response can then be used to complete a field on a record directly, or for other use cases, be sent back as a response to the Agentforce action that triggered the prompt being used. The response can then be used however you need – to update a record, create a task, send a message, or anything else the process calls for.
Step-by-Step: Build a Template-Triggered Prompt Flow in Salesforce
Let’s say your sales team wants quick, AI-generated summaries of recommended products tailored to a lead’s industry. Instead of manually writing this up, you can use a Template-Triggered Prompt Flow to automatically generate field-level summary content grounded in real Salesforce data.
Here’s how to build it…
1. Turn On Einstein
- Before building anything, make sure the right Einstein settings are enabled.
- From Setup, type Einstein Setup into the Quick Find box and open it.
- Turn on Einstein.
- Also, make sure Field Generation Templates are supported in your org.
- This unlocks the ability to use flows that generate content for fields using prompt templates.

2. Create the Flow That Grounds the Prompt
This flow will collect product data and prepare it for AI to generate the field summary.
- In Setup, search for Flows.
- Click New Flow.
- Choose Start from Scratch, then click Next.
- Select Template-Triggered Prompt Flow, then click Create.
In the right panel:
- Click Automatic Inputs.
- For Prompt Template Type, select Field Generation Template.
- For Object, choose Lead.
This means the prompt will be used to generate a field value on a Lead record.
3. Get Relevant Records for Context
Now, add logic to pull in the most relevant product information based on the lead’s industry.
- Add a Get Records element.
- Object: Product2
- Condition: Family equals {$Input.RelatedEntity.Industry}
- How Many Records to Store: All
- Store Output: Automatically store all fields
Note: Make sure the fields you’re using in the prompt, like Product Name, Key Features, and Unique Benefits, actually have values. If these fields aren’t required, it’s a good idea to build in fallback logic or validations to avoid generating incomplete or awkward outputs.

- Next, add a Decision element to check if any products were found:
- Label: Check for Product Recommendation
- Add an outcome:
- Label: Product Recommendation Found
- Condition:
- Resource: your Get Records collection
- Operator: Is Null
- Value: False

- Update the Default Outcome to: No Product Recommendation Found.

- Under the No Product Recommendation Found path, add an Add Prompt Instructions element:
- Label: Add Note About No Recommended Products
- Prompt Instructions: There are no recommended products.

4. Loop Through Matching Products
- If matching products are found, add a Loop element to go through each one. Inside the loop, use Add Prompt Instructions to send helpful product details to the AI, such as:
- Product Name
- Key features
- Unique benefits
- Use the current item from the loop to populate the values dynamically. These instructions will shape the final AI-generated summary.

5. Save and Activate the Flow
Once everything is in place:
- Click Save, and name the flow something like Add Product Recommendations to Prompt.
- Click Activate.
This flow is now ready to be used in a Field Generation Prompt Template.
Real-World Use Cases
Template-Triggered Prompt Flows open up a lot of creative ways to save time and improve the quality of communication across your org. Here are some ways teams are already putting them to work:
- Sales teams:
- Generate lead or opportunity summaries that reflect real-time engagement, such as recent website activity, emails opened, or product interest. These summaries can help reps personalize their outreach or even populate key fields like “Next Best Action.”
- You can also use flows to generate internal notes or Slack messages that keep account execs in the loop without needing to dig through record history.
- Service teams:
- Create case wrap-up summaries using details from the case, related tasks, and case comments. The AI can turn those into a clean, readable summary for internal use or customer follow-up. This works great for handoffs between teams or adding context before escalation.
- You can also automate suggested reply drafts that agents can edit and send, cutting down response time while keeping the tone and context consistent.
- Internal operations:
- Summarize record activity for regular check-ins. For example, a weekly account summary that pulls in recent changes across Contacts, Opportunities, or Cases. These can be posted to Chatter, stored in fields, or sent as internal updates.
- Marketing teams:
- Automatically generate campaign brief summaries based on related assets, goals, or engagement metrics. This can help prep cross-functional teams with a quick overview before a launch or review.
- HR and onboarding:
- Generate onboarding task summaries for new hires based on their role, department, and status. You could also summarize feedback from 30-60-90 day check-ins to help managers quickly spot themes.
Final Thoughts
Template-Triggered Prompt Flows take prompt automation in Salesforce to the next level. Instead of simply inserting field values into a static message, you’re building flows that understand the context, apply logic, and generate smarter input before handing it off to the AI.
This makes your automation feel less robotic and more thoughtful. Whether you’re generating follow-ups, internal summaries, or case resolutions, these flows help you deliver content that actually makes sense for the moment.
It’s especially useful for teams who deal with high volumes of communication and want to keep things consistent without losing that personal touch. If you’re already comfortable building in Flow, this fits right into your toolkit. Try experimenting with a few different scenarios. You might start with a simple use case like a summary. But as you experiment, you’ll find more ways to simplify work, save time, and support your team with content that actually feels human.
The Author
Viktoriya Mishchuk
Viktoriya is a Salesforce Technical Lead Admin at MagicFuse, with expertise in automation, optimization, and customization across sectors.