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

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Draft reply

> Create an unsent reply in an existing Gmail conversation.

`draftReply` creates an unsent reply to a specific Gmail message. It derives
the recipient, subject, and conversation headers from that message, which keeps
the draft attached to the original thread.

## Example

```ts automations/draft-inbox-reply.automation.ts theme={null}
import { automation } from "automate.ax"
import { draftReply, onNewEmail } from "automate.ax/gmail"

export default automation("Draft replies to new email", () => {
  const email = onNewEmail()

  draftReply({
    messageId: email.messageId,
    text: "Thanks for your message. A teammate will review this reply.",
  })
})
```

The `messageId` must identify the message being answered, not merely another
message in the same thread.

## Inputs

| Input         | Type                                              | Required | Default               | Description                                                                                           |
| ------------- | ------------------------------------------------- | -------- | --------------------- | ----------------------------------------------------------------------------------------------------- |
| `messageId`   | `string`                                          | Yes      | —                     | Immutable Gmail ID of the message receiving the reply.                                                |
| `replyAll`    | `boolean`                                         | No       | `false`               | Include the original To and Cc recipients, excluding the connected account and primary reply address. |
| `html`        | `string`                                          | No       | None                  | HTML reply body.                                                                                      |
| `text`        | `string`                                          | No       | Derived from `html`   | Plain-text reply body.                                                                                |
| `to`          | `Recipient \| Recipient[]`                        | No       | None                  | Additional primary recipients appended to the derived recipient.                                      |
| `cc`          | `Recipient \| Recipient[]`                        | No       | None                  | Additional carbon-copy recipients.                                                                    |
| `bcc`         | `Recipient \| Recipient[]`                        | No       | None                  | Additional blind-copy recipients.                                                                     |
| `from`        | `Recipient`                                       | No       | Gmail account address | Sender address or configured Gmail send-as alias.                                                     |
| `replyTo`     | `Recipient \| Recipient[]`                        | No       | None                  | Addresses that should receive replies to this draft.                                                  |
| `attachments` | `Attachment[]`                                    | No       | `[]`                  | Files and inline MIME parts attached to the reply.                                                    |
| `headers`     | `Record<string, string>`                          | No       | None                  | Additional RFC 5322 headers.                                                                          |
| `priority`    | `"high" \| "normal" \| "low"`                     | No       | Not set               | Importance encoded in standard message headers.                                                       |
| `account`     | `string \| IntegrationAccountReference<"google">` | No       | Project default       | Connected Google account that owns the draft.                                                         |

`Recipient` is an email string or `{ address: string; name?: string }`.
`Attachment` is a `File` or an object containing `file` with optional
`filename`, `contentId`, and `disposition: "attachment" | "inline"`.

Every input, including `account`, also accepts a compatible `Signal`.

<Warning>
  `replyAll: true` may add every original To and Cc recipient. Review the draft
  before sending when the conversation contains sensitive recipients.
</Warning>

Gmail must return the source message's thread ID, subject, RFC Message-ID, and
either Reply-To or From header. The action fails if those reply headers are
missing.

## Output

Returns a `Signal<DraftIdentifier>` with:

| Property    | Type                  | Description                                                               |
| ----------- | --------------------- | ------------------------------------------------------------------------- |
| `draftId`   | `string`              | Immutable Gmail draft ID. Use this with draft actions.                    |
| `messageId` | `string`              | Immutable ID of the reply message stored in the draft.                    |
| `threadId`  | `string`              | Gmail thread containing the original message and reply draft.             |
| `historyId` | `string \| undefined` | Latest mailbox history record affecting the draft message, when supplied. |
| `labelIds`  | `string[]`            | Labels applied to the draft message.                                      |
