> ## Documentation Index
> Fetch the complete documentation index at: https://flywheel.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Email

> Send builder-defined email content to a specific user from an agent

<iframe src="http://localhost:3000/doc-comp-previews/agent-node-preview?type=send_email" title="Agent Node Preview" width="100%" height="220px" className="border dark:border-[#1C1C20] rounded-xl" />

## How Email works

Use **Email** when you want the agent to execute a preconfigured email action. The agent decides when to use the tool, while you control the sender, subject, and body defaults in the builder. This gives you full control over the messaging content while letting the agent handle timing and recipient selection based on real-time context.

Email is ideal when your copy is already approved and consistent messaging matters more than personalization. Because all content is builder-defined, the agent cannot modify the email body — it simply triggers delivery when conditions are met during the run.

## Configuration

<Columns cols={2}>
  <Card title="Inputs">
    <ParamField path="Prompt" type="string">
      Instructions that define when this tool should be used.
    </ParamField>

    <ParamField path="Send to (`params.to_id`)" type="string" required>
      Flywheel user ID to receive the email.
    </ParamField>

    <ParamField path="Sender (`params.sender_config_id`)" type="string" required>
      Sender configuration to use for delivery.
    </ParamField>

    <ParamField path="Subject (`params.subject`)" type="string">
      Subject used for this message.
    </ParamField>

    <ParamField path="Preview (`params.preview_text`)" type="string">
      Optional email preview text.
    </ParamField>

    <ParamField path="CC (`params.cc_emails`)" type="string[]">
      Optional CC recipients.
    </ParamField>

    <ParamField path="BCC (`params.bcc_emails`)" type="string[]">
      Optional BCC recipients.
    </ParamField>

    <ParamField path="Complete on send failure (`params.complete_on_send_failure`)" type="boolean" default="true">
      Whether the run should continue when send fails.
    </ParamField>
  </Card>

  <Card>
    <iframe src="http://localhost:3000/doc-comp-previews/agent-config-preview?type=send_email" title="Agent Config Preview" width="100%" height="520px" className="" />
  </Card>
</Columns>

<Card title="Outputs">
  <ParamField path="status" type="enum" required>
    The status of the email send operation. Can be `success`, `failure`, or `skipped`.
  </ParamField>

  <ParamField path="to_id" type="string" required>
    The ID of the user that the email was sent to.
  </ParamField>

  <ParamField path="sender_config_id" type="string" required>
    The ID of the sender configuration used for the email.
  </ParamField>

  <ParamField path="email_id" type="string">
    The ID of the email that was sent (available on success).
  </ParamField>

  <ParamField path="create_email_options" type="object">
    The options used when creating the email, including subject, preview text, and recipients (available on success).
  </ParamField>

  <ParamField path="create_email_response" type="object">
    The response from the email creation service (available on success).
  </ParamField>

  <ParamField path="code" type="enum">
    The code indicating why the email send operation failed or was skipped. Can be `resend_error`, `duplicate_email`, or `user_marketing_email_opt_out`.
  </ParamField>

  <ParamField path="error_message" type="string">
    The message of the error that occurred (available on failure).
  </ParamField>
</Card>

## Use cases

**Onboarding Completion**

```
Condition: User completed onboarding checklist
Action: Send preconfigured welcome email with next steps
Outcome: User receives consistent onboarding messaging immediately after setup
```

**High-Intent Follow-Up**

```
Condition: Agent classifies user as high intent based on activity signals
Action: Send tailored follow-up using builder-defined template
Outcome: Qualified lead receives timely outreach without manual intervention
```

**Renewal Reminder**

```
Condition: User subscription renewal date is within 14 days
Action: Send renewal reminder email with plan details
Outcome: User is prompted to renew before their subscription lapses
```

**Feature Adoption Nudge**

```
Condition: User has not activated a key feature after 7 days
Action: Send feature education email highlighting benefits and setup guide
Outcome: Drive feature adoption with well-timed product education
```

## Best practices

**Content Control**

* Keep all email content builder-defined to ensure brand consistency and compliance review.
* Use this tool instead of AI-generated variants when the copy must match an approved template exactly.
* Pair with preview text to improve open rates in inbox clients.

**Failure Handling**

* Enable `complete_on_send_failure` when the agent run should proceed even if the email fails.
* Monitor `code` output values like `duplicate_email` and `user_marketing_email_opt_out` to understand skip reasons.
* Log `error_message` output for debugging delivery issues in BetterStack.

**Targeting and Timing**

* Use the agent prompt to define clear conditions for when this tool should fire during a run.
* Avoid sending duplicate emails by checking recent send history through agent context.
* Combine with other tools like Set Custom Property to mark users after email delivery.
