Skip to main content

Is it possible to ask an agent to draft an email using a specific email template? I would like to be able to ask my agent something like, "Draft an email response for this case using this "My Template Name" email template. We have several hundred email templates used across our org by the many different Teams.

답변 4개
  1. 9월 29일 오전 5:21

    Hi @James Waltz

     

    Yes, but I couldn't confirm it works out of the box. The reliable route is a small custom agent action. 

    What I verified 

    • Employee-facing agents have a standard Draft or Revise Email action, which the reasoning engine picks automatically for drafting emails. It generates text with the LLM. I couldn't confirm it can take a template name and merge that template's content. The Help page for that action didn't load for me, so check it in your org.
    • The Agentforce Service Agent on Email feature does use a Lightning email template, but only as a single wrapper structure for autonomous replies. It isn't a "pick any template on request" mechanism, so it doesn't fit your use case.

     

    What I'd recommend (my design, not a documented feature)

     

      

    Build a custom agent action, a Flow first, with Apex only if needed: 

     

    1. Inputs: template name and Case ID, collected from the rep's prompt.
    2. Lookup: query EmailTemplate by name. With hundreds of templates, return the top few matches when the name is ambiguous, and let the agent ask the rep to pick one.
    3. Render: merge the template against the Case, using Apex Messaging.renderStoredEmailTemplate or an equivalent Flow approach.
    4. Return: hand the rendered body back to the agent. Optionally pass it through Draft or Revise Email to tailor the tone to the case.
    5. Draft only: never send from this action. Have the rep review and send.

     

    Things to check before building

     

     

    • Access: confirm the action respects template folder sharing, so reps only get templates they can already see. This matters with many teams' templates in one org. I haven't verified how the agent's running user affects this, so test it.
    • Template type: Lightning and Classic templates use different merge syntax ({{{Case.Subject}}} vs {!Case.Subject}), so confirm which types you have.
    • Naming: with this many templates, exact-name matching will be brittle. A naming convention or a metadata field such as team or use case will help.

    I hope you find the above information helpful. If it does, please mark it as Best Answer to help others too.

0/9000