# AI Agent

The AI Agent is the core feature of MailAgent. When enabled, it autonomously monitors your inbox for new emails and generates responses based on your configuration.

## Enabling the Agent

At the top of the MailAgent sidebar, you'll find the **AI Agent** toggle switch:

* **ON** — The agent actively watches for new unread emails and responds automatically.
* **OFF** — The agent is inactive. You can still process emails manually.

## How It Works

When the AI Agent is enabled:

1. **Gmail Push Notifications** — Gmail sends a notification to MailAgent whenever a new email arrives.
2. **Thread Analysis** — The agent reads the full email thread for context.
3. **Response Generation** — Using your configured system prompt, integrations, and email history, the AI generates an appropriate response.
4. **Action** — Depending on your [Draft Mode](https://support.mailagent.email/gmail-addon/draft-mode) setting:
   * **Draft Mode ON** — A draft is created for your review.
   * **Draft Mode OFF** — The email is sent automatically.
5. **Labeling** — The email is labeled according to your [Email Labels](https://support.mailagent.email/gmail-addon/email-labels) configuration.

## Daily Limits

Your subscription plan determines how many emails the agent can process per day:

| Plan     | Daily Limit |
| -------- | ----------- |
| Starter  | 10          |
| Standard | 50          |
| Pro      | Unlimited   |

The current usage count is displayed below the agent toggle. When you reach your limit:

* The agent will stop processing new emails.
* You'll see a notification with your current usage.
* The counter resets automatically every 24 hours.

## Best Practices

* **Start with Draft Mode ON** — Review the AI's responses before letting it send emails directly. This helps you fine-tune the system prompt.
* **Write a clear system prompt** — The more specific your [Custom Prompt](https://support.mailagent.email/gmail-addon/custom-prompt), the better the AI's responses will match your expectations.
* **Connect knowledge bases** — Add [GitBook integrations](https://support.mailagent.email/gmail-addon/integrations) so the AI can reference your product documentation for accurate answers.
* **Use classification labels** — Set up [Email Labels](https://support.mailagent.email/gmail-addon/email-labels) so you can easily track what the agent has handled.

## Automatic Deactivation

The agent will automatically disable itself if:

* Your Google OAuth token expires and cannot be refreshed.
* Your daily email limit is reached.
* There is a persistent authentication error.

When this happens, you'll need to re-enable the agent manually from the sidebar.
