GuidesGmail and Outlook for agents
DocsGuidesHow to give an AI agent access to Gmail and Outlook

How to give an AI agent access to Gmail and Outlook

Connect an AI agent to Gmail with co auth google or Outlook with co auth microsoft. No OAuth app to register; the agent reads, searches, sends and replies with co gmail and co outlook.

Run co auth google for Gmail or co auth microsoft for Outlook. The consent runs through OpenOnion's OAuth app, so you don't register an app of your own, and the credentials are saved only on your computer. After that, any agent that can run a shell uses co gmail or co outlook to list, read, search, send and reply. Both also cover the calendar.

1. Install and sign in

Install the package and create the agent's identity.

pip install connectonion
co init

2. Connect the account

Pick the provider. Each opens the provider's consent page once.

co auth google       # Gmail, Calendar, Drive, YouTube
co auth microsoft    # Outlook mail, contacts, calendar

3. Read and search mail

Listings are numbered. To use a row number, pass the listing ID printed beside it.

co gmail inbox --unread
co gmail search "from:billing@example.com newer_than:7d"
co gmail read 2 --listing <listing-id>
co outlook inbox
co outlook search "invoice"

4. Send and reply

Outlook can schedule a send with --at and cancel it before it goes out.

co gmail send alice@example.com "Weekly report" "Attached." --attach report.pdf
co gmail reply <message-id> "Thanks, on it."
co outlook send bob@example.com "Tomorrow" "See you at 10." --at +2h

5. Use the calendar

The same logins cover Google Calendar (with Meet links) and the Outlook calendar (with Teams meetings).

co gcalendar today
co gcalendar free 2026-09-28 --minutes 30
co outlook calendar today

FAQ

Do I need to register an OAuth app?

No. co auth google and co auth microsoft use OpenOnion's OAuth apps. The credentials come back encrypted to a one-time key your CLI generated and are saved only on your computer.

Can the agent draft without sending?

Yes. co gmail draft create makes an unsent draft, and co gmail draft send requires a review token or an interactive confirmation.

How does an agent written in Python use it?

It can call the same co commands through a shell tool, or use ConnectOnion's Gmail and Outlook tools from the Python SDK.

Can I use more than one Google account?

Yes. Credentials are saved to the selected env file. Put --env-file /absolute/path/.env before a command to use a project's own file.

Updated 2026-09-26. Commands checked against ConnectOnion 1.8.8.

Star us on GitHub

If ConnectOnion saves you time, a ⭐ goes a long way — and earns you a coffee chat with our founder.