Skip to main content

Easily create AI Agents in MS Outlook

Project description

You've Got Mail

Easily build AI Agents in MS Outlook.

Introduction

MS Outlook is one of the most popular email clients among enterprises and business users. In some roles - handling email is almost the entire job. People receive emails, extract data from them, pass that data to other systems, retrieve data from those systems and send it via email. And so it goes.

Hence, building AI solutions that can

Furthermore, emails are a natural communication method that humans know and use daily. Creating AI Agents that can live in an email environment offers a natural way of interacting with AI systems. For example an AI CC'd into a conversation could easily perform tasks that the parties of the email thread want handled.

Building integrations into MS Outlook is particularly painful. because (as all things Microsoft) the API has many rules that make it time-consuming to build anything.

This library is meant to facilitate that. At the same time it will offer 3 types of AI solutions:

  • a set of AI helper functions meant to facilite the work with email retrieval and email sending (e.g. structured outputs from emails)
  • an AI Agent that lives in your inbox and handles email work for you
  • an AI agent that acts as a standalone inbox operatord can be used as an AI interface

cover_image

Quickstart

You will first need to set-up MS email credentials for your inbox. See Getting MS credentials and setting up your inbox for instructions. If you have those credentials, you can run the code below.

pip install yougotmail
import os
from yougotmail import YouGotMail

inbox = "yougotmail@outlook.com" # the email address of the inbox on which you will be operating

ygm = YouGotMail(
    client_id=os.environ.get("MS_CLIENT_ID"),
    client_secret=os.environ.get("MS_CLIENT_SECRET"),
    tenant_id=os.environ.get("MS_TENANT_ID")
)

emails = ygm.get_emails(
    inbox=[inbox], # list of inboxes from which you're retrieving emails
    range="last_30_minutes", # the time range 
    attachments=False # whether to include attachments in the emails or not
)

"""
Possible time ranges are
- previous_year (year before the the current year, e.g. 2024 if the current year is 2025)
- previous_month
- previous_week
- previous_day

- last_365_days (last 365 days until the current date)
- last_30_days
- last_7_days
- last_24_hours
- last_12_hours
- last_8_hours
- last_hour
- last_30_minutes
- last_hour
- last_30_minutes
"""

Getting MS credentials and setting up your inbox

To connect yougotmail to your Outlook inbox we need to do 3 things:

  1. Create a new "app" in Azure Entra
  2. Grant this app permissions to access the various email functionalities (read, draft, send)
  3. Retrieve 3 unique ids that will be used to authenticate access to the inbox:
    • client_id
    • client_secret
    • tenant_id

Step 1: Login to your Microsoft Entra account at https://entra.microsoft.com/

You can use your normal MS login. Ideally you should be the admin user in your org. If not that's ok, we will need to ask the admin to authorize the specific conditions.

Step 2: Go into Applications & Retrieve the Tenant Id

Once logged in, you can go into Applications. In the main Applications Dashboard you should see the tenant id for your org. You can copy it from here and store it.

ms_setup_1.png

Step 3: Under Applications, go into App registrations

Click on "New registration" to create a new app.

ms_setup_2.png

You can select "Accounts in this organizational directory only (Your Organization Name only - Single tenant)"

ms_setup_3.png

Step 4: Retrieve the client_id

Once created, you can grab the "Application (client) ID" from the application's dashboard. This is our "client_id".

Almost there - 2 down - 1 to go!

ms_setup_4.png

Step 5: Create a new secret

In the sidebar of the application (not your Entra sidebar) you have "Certificates & secrets". In there you can click on "New client secret". A new secret will be created - you can copy the id in the "Value" columne (NOT one in the "Secret ID" - thanks Microsoft for this create UX!). You have now your "client_secret" that we will use to instatiate the YouGotEmail class. Success!

Note: the secret will expire after 6 months. The date is shown in the Expires column. Make a note of it and set-up some calendar reminders.

ms_setup_5.png

Step 6: Grant your app permissions to the email API

The final thing we need to do is grant your app permissions to the email API.

In Microsoft APIs select MS Graph.

Select "Application permissions".

From the list of API permissions select all related to email. You can type "Mail" in the search bar.

Finally, each permission requires Admin access. If you're the Admin you can click on the button at the top of the permissions table. If you're not, you need to send a request to your admin.

ms_setup_6.png

ms_setup_7.png ms_setup_8.png ms_setup_9.png

Step 7: Run Quickstart code

You can now run the Quickstart code by passing

Roadmap & Planned functionalities

I will be releasing updates every few days after I complete the testing for the given functions.

Here are the planned capabilities:

  1. Retrieve Emails
  2. Retrieve conversations
  3. Retrieve attachments
  4. Send emails
  5. Reply to emails
  6. Storage in MongoDB and AWS
  7. AI features for parsing emails
  8. An AI agent that performs tasks in your inbox for you
  9. A standalone AI agent that owns and runs a given inbox (and can perform specific actions - e.g. check database)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yougotmail-0.0.3.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yougotmail-0.0.3-py3-none-any.whl (36.9 kB view details)

Uploaded Python 3

File details

Details for the file yougotmail-0.0.3.tar.gz.

File metadata

  • Download URL: yougotmail-0.0.3.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for yougotmail-0.0.3.tar.gz
Algorithm Hash digest
SHA256 adccf0a99baee97dc84d132aeef9a7235eef0ca1e63f65da9d28111e08f1b361
MD5 1935eba165fbba1cb1ab449983046155
BLAKE2b-256 5cfe723026dc81f84535047ff4d3771b9b94678675cb2a8899433c05c0ae2c3f

See more details on using hashes here.

File details

Details for the file yougotmail-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: yougotmail-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 36.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for yougotmail-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3df1615634ea1decb5b59e82db1925b4a0ba267d105842239aeb0621e0d39c14
MD5 a9520e3bb63231770f3a08b3cabc250d
BLAKE2b-256 7ca6e9f57302836d924211939e08a036da095eb0eb0db33ac3567607223b2d70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page