Microsoft 365

Let your agents read and write Outlook mail and calendar, read contacts and find OneDrive and SharePoint files, each member signed in with their own Microsoft work or school account.

Overview

Microsoft 365 is a ready-made connector. An organization admin registers an app in Microsoft Entra once and enters it in the 2kw.ai console; agent authors then add one connector URL to their agents, and each member connects their own account in the chat app.

AreaWhat an agent can do
ProfileRead the signed-in member's profile
MailList folders, list and read messages, read a message as an .eml file, list a message's attachments and read each as a file, create drafts, attach a file to a draft, send, reply, reply all, forward, move a message to another folder, mark it read or unread, flag it, set its categories
Shared mailboxesList a shared mailbox's folders and subfolders, list and read its messages, list a folder's messages, read a message as an .eml file, list its attachments and read each as a file, create drafts, attach a file to a draft, send, reply, reply all, forward, move a message to another folder, mark it read or unread, flag it, set its categories
CalendarList calendars and events, find meeting times, create and update events, accept, decline or tentatively accept invitations
ContactsList and read contacts
OneDriveList the member's drives, browse folders, read a file's or folder's details, search a drive for files
SharePointSearch for sites, read a site, list its document libraries, browse and search a library like a drive

You choose which of these areas agents get, and whether mail and calendar are read-only; an agent sees only the tools your choice covers. A new registration starts with every area at read and every write and send off. See Choose the permissions.

An agent has no tool that deletes, and cannot reach Teams or To Do. In OneDrive and SharePoint an agent finds files but cannot read their content yet; see OneDrive and SharePoint files. It can move a message to another folder, Deleted Items included, but never into the Recoverable Items folders: a move goes to a well-known folder such as inbox or archive, or to a folder id that 2kw.ai finds in the mailbox's folders, and any other destination is refused. Your mailbox's retention settings may then delete a message in Deleted Items for good, as they do for any message there. In Auto, the automatic approver decides moving a message, marking it read or unread, flagging it and setting its categories. An agent sets at most 10 categories on a message, each at most 64 characters on one line, without commas or semicolons. Every other tool that writes, such as sending, replying, forwarding, creating drafts and changing events, waits for a person's approval in Auto too; see Approvals.

Mail and attachments as files

An agent reads a message as an .eml file and each attachment as a file, and the files are stored like any file a connector's tool returns: the agent hands them on by id. An attachment list shows each attachment's name, type and size, not its content. A file can be up to 25 MB; a mail larger than that is read attachment by attachment.

An agent also attaches a file to a draft: it creates the draft, attaches the file by setting the attachment's contentBytes to backbone:file:{id} (see Using a File in a Turn), and then sends the draft. An attachment can be up to 3 MB; a larger file is not attached. In Auto, each of these steps waits for a person's approval.

OneDrive and SharePoint files

An agent browses and searches the files the member can open: their own OneDrive, files others shared with them, and the document libraries of SharePoint sites they can reach. It reads a file's or folder's details, such as its name, size, type, who changed it last and when, and its link. It cannot read a file's content or upload, move, rename or share files yet: it names the files it found and hands the member each file's link to open in the browser. No content of a file leaves Microsoft.

A search returns at most 25 results and a folder listing at most 50 items. A search may use letters, digits, spaces and . , _ : @ + -. An agent finds a SharePoint site by searching for it, then lists its libraries.

Before you start

  • A Microsoft Entra role that may register applications in your tenant, such as Application Developer or Application Administrator.
  • The Admin or Owner role in your 2kw.ai organization.
  • Members sign in with work or school accounts of that tenant. Personal Microsoft accounts are not supported.

Choose the permissions

The Add Microsoft 365 dialog (see Enable it in the console) has one row per area, each Off, Read or Write (areas without writes offer Off and Read), and a few switches under their area. A new registration starts with every area at Read and every switch off. Turn on what your organization wants agents to do; the dialog lists the Microsoft Graph permissions your choice needs, and those are the ones to add in Microsoft Entra.

Area or switchOptionsPermissions it needs
MailOff, Read, WriteMail.Read, or Mail.ReadWrite for write (draft, move, mark, flag, categorize)
Send mail (under Mail)On, OffMail.Send
Shared mailboxes (under Mail)On, OffThe shared-mailbox version of each mail permission above: Mail.Read.Shared or Mail.ReadWrite.Shared, and Mail.Send.Shared
CalendarOff, Read, WriteCalendars.Read, or Calendars.ReadWrite for write
Meeting times (under Calendar)On, OffCalendars.Read.Shared
ContactsOff, ReadContacts.Read
OneDriveOff, ReadFiles.Read.All
SharePointOff, ReadSites.Read.All

User.Read is always needed: it signs the member in. Calendars.Read.Shared lets an agent find meeting times: it reads the free/busy times of the people invited, and only what the member can already see in Outlook. Meeting times needs Calendar at Write. Shared mailboxes follows your mail and send settings, so turning off Send mail also stops sending from shared mailboxes, and with Mail off and Send mail off the switch does nothing. Files.Read.All reads the files a member can open, including files shared with them; Sites.Read.All reads the SharePoint sites they can reach. Agents get only the tools your choice covers.

Register the app in Microsoft Entra

1

Create the app registration

In the Microsoft Entra admin center, open Identity → Applications → App registrations and choose New registration.

  • Name: anything your members recognize, for example 2kw.ai agents. They see it when they sign in.
  • Supported account types: Accounts in this organizational directory only.
  • Redirect URI: platform Web, value https://chat.2kw.ai/connectors/callback.

Choose Register.

2

Add the Microsoft Graph permissions

Open API permissions → Add a permission → Microsoft Graph → Delegated permissions and add the permissions the dialog lists for your choice. Having more permissions from the list below is harmless: agents still get only the tools your choice covers. Having fewer asks members to sign in again until you add them. The permissions an area can need:

PermissionUsed for
User.ReadWho the member is
Mail.ReadReading mail
Mail.ReadWriteReading mail, creating drafts, moving, marking and flagging messages
Mail.SendSending, replying and forwarding
Calendars.ReadWriteReading and changing events
Calendars.Read.SharedFinding meeting times from the attendees' free/busy
Calendars.ReadReading events
Contacts.ReadReading contacts
Files.Read.AllBrowsing and searching OneDrive files
Sites.Read.AllFinding SharePoint sites and browsing their libraries
Mail.Read.SharedReading mail in shared mailboxes
Mail.ReadWrite.SharedReading mail, creating drafts, moving, marking and flagging messages in shared mailboxes
Mail.Send.SharedSending, replying and forwarding from shared mailboxes

Then choose Grant admin consent for the tenant. Many tenants do not let members agree to these permissions themselves, and a tenant's consent policy may require an administrator for Files.Read.All and Sites.Read.All; without admin consent they see Need admin approval when they connect. With it, members are not asked to agree to the permissions. At sign-in, members also see Maintain access to data you have given it access to: it lets 2kw.ai renew their sign-in without asking again.

3

Create a client secret

Open Certificates & secrets → Client secrets → New client secret, pick an expiry and choose Add. Copy the secret's Value right away; Entra shows it only once. The Secret ID is not needed.

Put a reminder in your calendar a few weeks before the expiry. See When the secret expires.

4

Copy the two IDs

On the app's Overview, copy the Application (client) ID and the Directory (tenant) ID.

Enable it in the console

Open Connectors in the console's sidebar and choose Add connector → Microsoft 365. Choose a level for each area; reading everything with writes off is the start. Enter the directory (tenant) ID, the application (client) ID and the client secret value, and keep the token endpoint auth method at client_secret_post unless your app requires client_secret_basic. Then choose Enable.

The dialog approves the hosts m365.mcp.2kw.ai and login.microsoftonline.com for your organization and registers your app for your tenant, showing each step as it goes. Approving those hosts lets agents reach any connector on the first and the sign-in pages of any Microsoft Entra tenant on the second; only your tenant gets a registration.

  • Running it again picks up where it stopped: a step that is already done is skipped.
  • A registration for your tenant already exists, for example from an earlier run: the dialog fills in its permission settings, shows its client ID, auth method and permissions next to the ones you entered, and you choose Use existing registration or Replace credentials. When you changed the areas, the first button reads Save permissions: it saves the new choice to the registration without a client secret, as long as the client ID and auth method are the registration's own. Replace credentials needs the client secret and asks every member connected through the old one to sign in again.
  • Your organization has reached its limit of approved hosts: the dialog stops and says so. Remove a host you no longer need under Connectors → Manage allowed hosts and OAuth clients and run it again.

Once the steps are done, the dialog shows your connector URL and tests it:

https://m365.mcp.2kw.ai/t/{tenant-id}/mcp

The tenant ID in the URL is lowercase. Choose Connect in the test result to sign in as yourself and see the tools.

Add it to an agent

Give the connector URL to your agent authors. In the console's agent editor they add a connector on the approved host m365.mcp.2kw.ai with the path /t/{tenant-id}/mcp, or declare it on the agent version:

{
  "type": "mcp",
  "server_label": "m365",
  "server_url": "https://m365.mcp.2kw.ai/t/{tenant-id}/mcp",
  "server_description": "The member's Outlook mail, shared mailboxes, calendar and contacts"
}

Once Microsoft 365 is enabled, the agent editor's connector form also offers a Microsoft 365 button for each tenant that fills in the host and path.

Levels per tool, approvals and the rest work as for any connector; see Connectors.

Changing the permissions

Change the areas by running Add Microsoft 365 again with the same tenant, client ID and auth method, and choosing Save permissions. No client secret is needed, and the registration's credentials stay as they are.

  • Giving agents more. Members who need the new areas sign in again once. Add the new permissions to the app in Microsoft Entra (API permissions, then Grant admin consent), before or after you save.
  • Giving agents less. It takes effect at once: members stay connected and agents get fewer tools. Microsoft keeps every permission the app was granted, which is harmless: agents get only the tools your choice covers. To take a permission away from the app too, remove it in API permissions and revoke the consent under Enterprise applications → your app → Permissions.

An edit under Connectors → OAuth clients (for example to rotate the secret) keeps the permissions as they are.

Set up before finding meeting times was added? Your registration keeps working with its seven permissions, but agents do not find meeting times. To add it, turn on Meeting times under Calendar and follow Giving agents more with Calendars.Read.Shared.

Shared mailboxes

An agent can work in a shared mailbox the member is allowed to open. It names the mailbox by its sign-in address (UPN), for example support@contoso.com. A mailbox whose address contains # is not supported. Microsoft cannot list the mailboxes a member may open, so the member or the agent's instructions give the address.

What the member can do depends on rights an Exchange admin gives them; 2kw.ai cannot grant them.

A member wants toExchange permission
List and read messages, create drafts in a mailboxFull Access (Read and manage) on it
Read a folder a colleague shared with themThat folder's permission, without Full Access
Send, reply, reply all, forwardSend As (the mail shows the mailbox as sender) or Send on Behalf (it shows member on behalf of mailbox) on it
Send a draft created in the mailboxFull Access, and either of the sending rights above

Without the right, Microsoft answers with an access error and the agent sees it as the tool's error. Where Microsoft files the sent copy, the mailbox's Sent Items or the member's own, depends on the mailbox's Exchange settings.

  • Folders. An agent lists a shared mailbox's folders and their subfolders to find a folder by name, such as a custom archive folder, and moves a message into it by the folder's id. Listing the folders, and moving by a folder's id, needs Full Access. Without it, an agent reaches folders by the well-known names inbox, drafts, sentitems, deleteditems, junkemail and archive, or by the folder id a listed message carries, and moves by well-known name.
  • Delegated folders and mailboxes. Agents also reach folders and mailboxes a colleague delegated to the member.
  • Members connected earlier sign in once more, so they agree to the two added permissions.

What members see

  • Connecting. A member connects on the chat app's Connectors page or from the card a paused chat shows. Microsoft's sign-in page opens in a new tab, lists the permissions your admin chose unless an admin already granted them, and returns to the chat.
  • Acting. An agent reads as the member. Before it sends, creates or changes anything, the member approves the call. In Auto the automatic approver decides moving, marking, flagging and categorizing messages; everything else still waits for the member.
  • Disconnecting. Disconnecting deletes the member's sign-in in 2kw.ai. Microsoft offers no way to revoke it from outside, so at Microsoft it stays valid until it expires, or until the member removes the app under My Apps or an Entra admin revokes their sessions.

When the secret expires

Once the client secret has expired, every member's connection needs a reconnect, and reconnecting fails until an admin enters a new secret. Create a new secret in Entra (step 3 above), then either run Add connector → Microsoft 365 again and choose Replace credentials, or edit the registration under Connectors → Manage allowed hosts and OAuth clients. Every member connected through it signs in again.

Was this page helpful?

A request failed? See Errors for every status and code.