Sub topic 11
Drafting and revising emails
This chapter covers the two standard email actions in Agentforce: Draft or Revise Email and, where your org offers it, Send Email. It assumes you can open Agentforce Builder and add an action to a topic, and that you know how actions take inputs and return outputs. Action names, and whether an action is available, vary by release and org. Check the action list in your own Builder before you follow the steps.
What the email actions do
An email action asks the large language model (LLM) to write or rewrite message text. It does not need to be a "send" step. In the typical standard setup, the agent produces a draft and shows it to the user. The user then copies it, edits it, or asks for changes.
Two jobs are involved:
- Draft: write a new email from a short description of the goal, plus any record context the agent has.
- Revise: take existing text and change it, for example shorter, more formal, or with a different call to action.
The model generates the text through a prompt. That prompt runs through the Einstein Trust Layer, so the same masking and logging rules apply as for other generative actions. A later chapter covers those rules.
Inputs and outputs
Email actions are only as good as the inputs the agent can fill. Typical inputs are:
| Input | Purpose | Where the value comes from |
|---|---|---|
| Goal or instruction | What the email should achieve | The user's request, or the topic instructions |
| Recipient or related record | Who the email is for and what it is about | A record found by an earlier action |
| Existing text | The draft to revise | The previous draft in the conversation, or text the user pastes |
| Tone or length hints | Style constraints | The user's request, or a rule in the topic instructions |
The output is the email text, usually a subject and a body. Later steps in the same turn can reuse it. A user can also refer back to it in the next message, for example "make it shorter".
Input names differ between actions and releases. Open the action in Builder and read each input's description. The agent fills inputs from the conversation and from earlier action outputs, so a clear description helps it choose the right value.
Add the action to a topic
- Open the agent in Agentforce Builder and select the topic that handles outreach, such as "Customer Follow-up".
- Choose to add an action and pick the email drafting action from the standard list.
- Review the inputs and outputs. For each input, decide whether the agent should collect it from the user or take it from a prior action's output.
- Save the action.
- Write topic instructions that say when to use it, and in what order.
Keep email actions in a topic whose scope covers email. If you put them in a broad topic with ten other actions, the agent has more chances to pick the wrong one.
Topic instructions that make drafting reliable
The classification description decides when the agent enters the topic. The instructions decide how it uses the actions inside it. For email work, write instructions that cover four things: the order of steps, where the facts come from, what style to use, and what happens to the draft.
Topic: Customer Follow-up
Classification description:
Help the user write or rewrite follow-up emails to customers about an account or a case.
Instructions:
1. When the user names an account or contact, first find the record, then use its details when drafting.
2. Use the draft action to write a new email. Use the revise action when the user supplies text or asks to change a previous draft.
3. Only use facts from the record or from what the user said. If a detail such as a date or price is missing, ask the user instead of inventing it.
4. Always show the full draft to the user. Do not tell the user the email has been sent.
5. If the user asks for a change such as shorter or more formal, revise the latest draft instead of starting over.Rule 3 matters most. An LLM will fill a gap with plausible text. Telling the agent to ask when a fact is missing is the cheapest guard against an invented discount or meeting time. Rule 4 prevents a common confusion: the user reads "Here is your email" as "I sent your email".
A worked conversation
The conversation below shows the chain: find a record, draft, then revise.
Three points to notice:
- The lookup runs first, so the draft can use real account data instead of guesses.
- The revision call receives the earlier draft as its existing-text input. If the agent loses track of which draft is latest, the revision may start from the wrong text. Rule 5 in the instructions reduces that risk.
- Each action call is a separate step you can inspect in the testing tools. You can check what the agent passed in and what came back.
Edge cases and common errors
- Missing recipient context. If the lookup finds no record, or more than one, the draft has nothing reliable to use. The earlier instruction to ask the user for clarification covers this case. Test it on purpose with an ambiguous name.
- Invented details. If a draft contains a fact you cannot find in the record or the conversation, tighten rule 3 and add the specific field names the agent may rely on.
- Tone drift. The agent may ignore a style request on the second revision. State the tone in the instructions if it must hold for every draft, for example "Use a polite, plain tone and keep emails under 150 words".
- Wrong action chosen. If the agent drafts anew when the user asked for a change, or the reverse, the instructions for draft and revise are probably too similar. Say plainly when each applies.
- Sensitive content. Record fields you pass in become part of the prompt. Pass only what the email needs. Field-level security and sharing rules still limit what the agent can read, but the agent can include anything it can read.
- Language and length. Without a rule, the model picks the language and length itself. If you serve several regions, say which language to use.
Sending is a separate decision
A draft in the chat window has no side effects. Sending does. If your org uses a send action, treat it like a record-change action: have the agent restate the recipient, subject, and body, and ask for confirmation before it runs. The same rule applies to updating a record, as covered in the chapter on creating and updating records. An unwanted email cannot be undone.
If you only offer drafting, say so in the topic instructions. Otherwise the agent may offer to send an email it cannot send.
Checking your work
Test in the Builder preview with at least these cases:
- A named account with a clear goal, to check that the lookup runs before the draft.
- A request with a missing fact, to check that the agent asks.
- Three revisions in a row ("shorter", "more formal", "add a closing line"), to check that each builds on the latest draft.
- An ambiguous account name, to check that the agent asks to clarify.
For each, open the action details and compare the inputs the agent passed against what you expected.
Exercise
A user asks the agent to "make the email friendlier", and the agent writes a completely new email that drops details from the earlier draft. Which two parts of the topic setup would you check first, and what would you change?
Show answer
Check the topic instructions and the revise action's existing-text input. In the instructions, state that changes such as tone or length must use the revise action on the latest draft instead of drafting anew. Then open the action call in the testing tools and confirm the previous draft was passed as the existing-text input. If it was empty or wrong, improve that input's description so the agent fills it with the latest draft.
Exercise
Write one topic instruction line that stops the agent from inventing facts in an email, and say why it works.
Show answer
For example: "Only use facts from the record or from what the user said. If a detail such as a date or price is missing, ask the user instead of guessing." It works because the model tends to fill gaps with plausible text, and an explicit rule to ask turns a gap into a question for the user.