> For the complete documentation index, see [llms.txt](https://support.mailagent.email/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.mailagent.email/widget/getting-started.md).

# Getting Started

Add the MailAgent chat widget to your website in under 5 minutes. Your users will be able to interact with an AI assistant that can draft emails, answer questions, and more.

## Prerequisites

* A MailAgent account with a **user ID**
* A website where you can add a `<script>` tag

## Quick Start

Add the following script tag to your HTML:

```html
<script
  src="https://widget.mailagent.email/connect/connect.js"
  data-user-id="YOUR_USER_ID"
></script>
```

Then open the widget from JavaScript:

```javascript
const widget = await MailAgent.open({
  bottom: "20px",
  right: "20px",
  width: "400px",
  height: "600px"
});
```

That's it. The widget will appear as a fixed-position chat window in the corner of your page.

## Finding Your User ID

The `data-user-id` is your MailAgent user ID — the unique identifier assigned to your account when you sign in with Google.

### From the Gmail Addon

The easiest way to find your user ID is in the Gmail addon:

1. Open Gmail and click the MailAgent icon in the sidebar.
2. Scroll to the bottom of the settings panel.
3. Your user ID is displayed under **"Your User ID"**.

## What Happens Under the Hood

1. The `connect.js` script loads and registers the global `MailAgent` object on `window`.
2. When you call `MailAgent.open()`, it creates a sandboxed `<iframe>` pointing to the MailAgent hosted app.
3. The iframe initializes with your user ID and configuration via `postMessage`.
4. Once ready, the widget fades in and your users can start chatting.

## Next Steps

* [Installation](/widget/installation.md) — All the ways to add the widget to your site.
* [Configuration](/widget/configuration.md) — Customize suggestions, colors, and header.
* [JavaScript API](/widget/javascript-api.md) — Control the widget programmatically.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://support.mailagent.email/widget/getting-started.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
