Skip to main content

Tempo stimato

Argomenti

Chiedi alla community

Refine Your Prompt Template for Accurate Agent Replies

Learning Objectives

After completing this unit, you’ll be able to:

  • Describe when to use a flow in a prompt template with agents.
  • Explain why testing in Prompt Builder and Agent Builder improves responses.
  • Demonstrate how to test an agent in Agent Builder with prompts in a live environment.

You’ve learned how to craft a prompt template, build an agent, and connect actions, but how do you know it’s working the way you expect? In this unit, you follow along as Becca shifts into quality assurance mode. You learn how to test an agent, identify unexpected behaviors, and revise the prompt to ensure the agent responds with accuracy and empathy every time.

Test Your Agent

Becca starts by simulating a guest interaction to see how the agent responds.

  1. In Agent Builder, click the refresh (circular arrow) icon in the top-right corner of the Conversation Preview window.

The Conversation Preview window

  1. Don’t worry if the dots are spinning in the Conversation Preview. Type this message and press Enter: The White Water Rafting experience my family and I booked was unexpectedly canceled.
  2. After the agent responds, enter this follow-up and press Enter: I’m sofiarodriguez@example.com and my membership number is 10008155.
Note

If the agent is unable to identify the guest information, re-enter it.

Let’s break down what’s happening.

  • A guest submits a complaint: The guest uses the agent in a chat to voice their complaint.
  • The agent responds: It asks for identifying details—email and membership number—because it needs to verify who the guest is.
  • The Get Customer Details action retrieves the guest information, including the case details, and verifies it through a flow.
  • Categorization of complaints: Based on the nature of the complaint, the agent classifies the issue into one of four tiers.
  • The agent responds: It provides a kind message offering compensation or a resolution. But it's offering Tier 2 compensation for a Tier 3 issue. That’s because it needs a bit more context.

And there's another problem… let’s try another prompt to see.

  1. In Agent Builder, click the refresh (circular arrow) icon in the top-right corner of the Conversation Preview window.
  2. Type this message and press Enter: At the Ocean Kayak Expedition, I didn’t like that the tour group was so large.
  3. After the agent responds, enter this follow-up: I’m tabathatobias@example.com and my membership number is 10009996. Press Enter.
Note

If the agent is unable to identify the guest information, re-enter it.

Becca notices something alarming.

Problem Detected

Even without an officially logged complaint or open issue, the agent is still offering compensation. That means anyone who says they didn’t like something could walk away with a free night or a big credit. Yikes! That’s not sustainable for Coral Cloud Resorts.

To fix these issues, Becca needs to update the Guest Experience Compensation prompt template so it has the context it needs and offers the right compensation if there’s an open case tied to the guest.

Modify the Prompt Template

She returns to Prompt Builder and updates the prompt template to include logic that helps the LLM determine the appropriate compensation tier based on open cases, while also guiding how to respond when a guest raises a separate issue that isn’t officially logged.

  1. Click Setup and select Setup.
  2. In the Setup Quick Find box, search for and select Prompt Builder.
  3. Click the Guest Experience Compensation prompt template.
  4. Replace the line, “Determine the appropriate tier of compensation based on the guidelines below.” Copy and paste the following text:

Use the details from the following case to determine the appropriate tier of compensation based on the guidelines below:


If the case details say "There are no open cases," or are empty or null, assign Tier 0.


Case Details:
Complaint:


If there is an open case, proceed with the appropriate compensation tier and include a brief
mention that their issue is part of an existing official complaint. If there is not an open case,
acknowledge the complaint, let the guest know it's appreciated, and that their preferences will be
noted for future stays.
  1. Click Save As > Save As New Version.

Activate a Flow to Use in a Prompt Template

Becca wants to use a flow that checks if the guest has any open cases and returns only those relevant details to the prompt template. Unlike a related list, which simply returns the first five cases regardless of status, the flow gives her more control. It filters for the specific case information she needs. In this example, she wants to return only open cases.

  1. Click Setup icon and select Setup.
  2. In the Setup Quick Find box, search for and select Flows.
  3. Select the Get Open Cases for Contact flow.

This flow checks for any open cases linked to the guest and returns them to the prompt template so the agent can respond.

  1. Click Activate so the flow can be used in the prompt template.
  2. In Flow Builder, click the back arrow Back arrow button to return back to Setup.

Connect the Flow to the Prompt Template

Now Becca adds that flow to her prompt template, so it can use only the open case data when crafting responses.

  1. In Setup, in the Quick Find box, search for and select Prompt Builder.
  2. Select the existing prompt template, Guest Experience Compensation.
Note

If you begin editing an active prompt template, you’ll need to save it as a new version or new template to test the changes.

  1. In the prompt after the text, Case Details:, add the flow in the prompt template. Click Insert Resource > Flows > Get Open Cases for Contact.
  2. In the prompt after the text, Complaint:, add the free text resource to the prompt. Click Insert Resource > Free Text > Complaint.
  3. Click Save.

Preview and Validate in Prompt Builder

Becca previews the updated template with real data.

  1. Click Preview and select Sofia Rodriguez in the Contact field and type, I didn’t like that the tour group was so large in the Complaint field.
  2. Click Preview again.

Now, she looks at the preview. The resolution shows the details of Sofia’s open case, her current complaint to the agent, the suggested compensation options based on her case, and a preview of the response.

  1. Click Activate to publish the updated prompt template.

Retest in Agent Builder

Becca goes back to Agent Builder and sees the full experience in action.

  1. In Setup, search for and select Agentforce Agents.
  2. Choose the Coral Cloud Experience Agent.
  3. Click Open in Builder.
  4. In the Conversation Preview, enter the same test prompt again: The White Water Rafting experience my family and I booked was unexpectedly canceled. Press the Return/Enter key.
  5. After the agent responds, enter the next prompt: I’m sofiarodriguez@example.com and my membership number is 10008155. Press the Return/Enter key.

She observes the improved response—now grounded in actual guest history!

Wrap It Up

In this module, you crafted a powerful prompt template, configured an agent, and then made sure it all worked in the real world.

You learned how to:

  • Design prompts that generate accurate, on-brand responses.
  • Connect prompt templates to agents through intelligent actions.
  • Use flows to power those prompts with real-time, contextual data.
  • Test and troubleshoot agent responses to prevent over-automation or incorrect logic.
  • Refine your solution based on real behavior—not just assumptions.

The key takeaway? Great agents aren’t just configured, they’re curated. They blend logic, language, and data to provide experiences that feel human and helpful. Prompt Builder gives you the precision. Agentforce gives you the automation. Together, they help you build smarter, safer, and more scalable AI-powered workflows.

Happy building!

Condividi il tuo feedback su Trailhead dalla Guida di Salesforce.

Conoscere la tua esperienza su Trailhead è importante per noi. Ora puoi accedere al modulo per l'invio di feedback in qualsiasi momento dal sito della Guida di Salesforce.

Scopri di più Continua a condividere il tuo feedback