# AI drafts

> How the AI writes a draft reply on a ticket, what it reads first, and why nothing reaches a customer until a person presses Send.

Lagotto's AI reads a ticket and writes a draft of the next reply. The draft waits on the ticket for an agent to read, change and send. The AI never emails a customer by itself: a draft leaves Lagotto only when an agent puts it in the reply box and presses **Send**.

AI is off in a new workspace. An administrator switches it on under **Settings → AI**: see [Setting up AI](https://www.lagottolabs.ai/support/ai/setting-up-ai.md).

## When a draft is written

- **When a customer writes.** With **Draft a reply when a customer writes** on (it is unless an administrator turns it off), a draft starts whenever a customer's message leaves an open ticket waiting for your reply.
- **When you ask.** On an open ticket, press **Draft with AI** in the **AI draft** panel. **Redraft** writes a fresh one, and **Try again** follows a draft that didn't finish.

One draft is written at a time on each ticket. When a customer sends several messages before a draft starts, the ticket gets one draft that has read them all, not one for each message. A message that arrives once a draft has started gets a fresh draft. Closed and spam tickets are not drafted: reopen the ticket first. Read-only seats see the panel but not its buttons.

## What the AI reads

Every draft reads:

- The whole conversation, oldest first, without the earlier thread a customer quoted. It sees the names of attached files, not what is in them.
- Internal notes, which it treats as direction from your team: a good way to steer a redraft.
- Your **Instructions for drafts** from **Settings → AI**.
- Earlier tickets in your workspace that look similar, with their summaries and last reply, and this customer's other tickets.

When the capability is on, it also reads:

- **Memories**: facts about your product and this customer, and your writing rules. See [Memories](https://www.lagottolabs.ai/support/ai/memories.md).
- **Knowledge base**: your help articles, so the draft can answer from them and link to them. See [Using your knowledge base in drafts](https://www.lagottolabs.ai/support/integrations/knowledge-base.md).
- **Source control**: your product's code in the repositories you switched on, to check how it really behaves. Drafts never paste code, file paths or internal names into a reply. See [Fixes and pull requests from GitHub](https://www.lagottolabs.ai/support/integrations/github-fixes.md).
- **Production data**: the records your product holds for the ticket's customer, never for anyone copied on the ticket. See [Showing your customers' data on tickets](https://www.lagottolabs.ai/support/integrations/customer-data.md).

## How drafts are written

A draft answers the customer's latest message, in the language they wrote in, and greets them by first name when it knows it. It leaves off the signature: yours is added when you use the draft. It doesn't promise a date, a refund, a fix or an exception that your documentation or an agent on the ticket hasn't confirmed, and says in the draft note what it couldn't confirm. Your instructions win over its default style.

## Reading a draft

The **AI draft** panel sits at the top of the right-hand column of the ticket. It shows:

- The **draft note** in bold: one or two sentences for you about what the draft is based on and what to check before sending.
- The draft itself. When it is in another language, **Show in English** opens an English version.
- "The customer has written since this draft." when a newer message has arrived. Press **Redraft** to answer it.
- **How this was written**: each step the AI took (such as "Searched the knowledge base" or "Looked at earlier tickets"), the model, the tokens used, the cost and who asked for it.

## Using a draft

1. Press **Use draft**. The draft goes into the reply box as a reply, with your signature underneath. If you have already typed something, Lagotto asks before replacing it.
2. Change whatever you like.
3. Press **Send** or **Send and close**.

**Discard** throws the draft away. Sending any reply clears the draft too.

In the queue, a ticket shows **Drafting…** while a draft is written and **Draft ready** when one is waiting. To list those, choose **Draft ready** under **AI status**. See [The ticket queue](https://www.lagottolabs.ai/support/tickets/the-ticket-queue.md).

## Proposed fixes

With source control on, a draft that finds the cause of a problem in your code, or data that needs a one-off correction, can propose a fix. It appears under the draft as **Proposed fixes**, and the ticket shows **Decision needed** in the queue. Nothing is written until someone presses **Open a pull request**, and nothing is ever merged by Lagotto. Until a pull request for the ticket has merged, drafts don't tell the customer a fix is on the way. See [Fixes and pull requests from GitHub](https://www.lagottolabs.ai/support/integrations/github-fixes.md).

## When there is no draft

- When AI can't run, the panel says why, such as "This workspace is out of AI credits." See [Why AI might not run](https://www.lagottolabs.ai/support/ai/setting-up-ai.md#why-ai-might-not-run).
- "The AI declined to write this reply." or "The draft couldn't be finished." means the last attempt failed, with the reason underneath. Press **Try again**.
- With AI switched off, only administrators see a note, "AI drafts are off.", with a link to set it up.

## What a draft costs

Each draft is one AI run, paid from your [AI credits](https://www.lagottolabs.ai/support/billing/ai-credits.md) on Lagotto's key, or billed by your AI provider on your own key. Its cost is under **How this was written**, and every run is listed under **Settings → AI → Usage**.
