Superbadge: Apex for Agentforce | Superbadge 面向 Agentforce 的 Apex(练习操作步骤)

《Superbadge: Apex for Agentforce | Superbadge 面向 Agentforce 的 Apex》的分步练习操作指南。...

📅 2026/10/2 ✍️ ponybai 🏷️ agentforce, salesforce, ai

本文是《Superbadge: Apex for Agentforce | Superbadge 面向 Agentforce 的 Apex》的练习操作步骤。阅读原文请见:Superbadge: Apex for Agentforce | Superbadge 面向 Agentforce 的 Apex。

1. Create an Invocable Apex Class

  1. In the existing GuestReviewProcessor Apex class, build an input wrapper class GuestReviewRequest with these required variables (all required = true, each with a description):
    • Contact contact
    • Experience__c experience
    • String review
    • String rating
  2. Build an output wrapper class GuestReviewResponse with an output String message (label status, with a description).
  3. Build an invocable method processReviews (label Process Guest Reviews, with a description) that:
    • Takes GuestReviewRequest as input.
    • Creates a guest review record with the captured Contact__c, Experience__c, Comments__c, and Rating__c.
    • Uses GuestReviewResponse to return a success message, or an error message on failure (best-practice exception handling).
  4. (Optional) Tie the record to the CampaignMemberController campaign functionality.

2. Invoke a Prompt Template From an Apex Class

  1. In GuestReviewRatingCalculator, in the generateRatingParams method, replace REPLACE_WITH_PROMPT_TEMPLATE_INPUT with the prompt template input.
  2. Set generationsOutput to call generateMessagesForPromptTemplate with the prompt template API name Experience_Guest_Reviews_Evaluator and the input parameters.
  3. Set the response using the generations property from generationsOutput.
  4. The rest of the code deserializes the response and updates the experience record with Value, Accuracy, and Communication.
  5. (Optional) Test by invoking generateRatingParams with the Beach Bootcamp Challenge experience record ID in Developer Console.

3. Configure an Apex Action for an Agent

  1. Update the Guest Reviews and Campaign permission set to grant the EinsteinServiceAgent User permission to use the GuestReviewProcessor Apex class.
  2. Create a new Apex agent action for the Coral Cloud Experience Agent named Process Guest Reviews (API name Process_Guest_Reviews).
  3. Assign this agent action to the Customer Experience Reviews topic.