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:
<script
src="https://widget.mailagent.email/connect/connect.js"
data-user-id="YOUR_USER_ID"
></script>Then open the widget from 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:
Open Gmail and click the MailAgent icon in the sidebar.
Scroll to the bottom of the settings panel.
Your user ID is displayed under "Your User ID".
What Happens Under the Hood
The
connect.jsscript loads and registers the globalMailAgentobject onwindow.When you call
MailAgent.open(), it creates a sandboxed<iframe>pointing to the MailAgent hosted app.The iframe initializes with your user ID and configuration via
postMessage.Once ready, the widget fades in and your users can start chatting.
Next Steps
Installation — All the ways to add the widget to your site.
Configuration — Customize suggestions, colors, and header.
JavaScript API — Control the widget programmatically.
Last updated