A shared or user mailbox through Microsoft Graph, scoped to one mailbox.
Install
npx shadcn@latest add @tendkit/channel-microsoft365It lands in lib/support/channels/. Import microsoft365Channel from there.
Set up
Register an app
Entra admin center → App registrations → New registration (single tenant). Copy the tenant and client ids and add a client secret.
Scope it to one mailbox
Don't grant Mail.* permissions in Entra: a tenant-wide grant overrides any scoping. Use Exchange RBAC for Applications instead, giving the app
Application Mail.ReadWriteandApplication Mail.Sendon a management scope that contains only the support mailbox. Changes can take up to two hours.Shared mailboxes
So replies agents send from Outlook with Send As reach the ticket, run
Set-Mailbox support@acme.com -MessageCopyForSentAsEnabled $true -MessageCopyForSendOnBehalfEnabled $true.Optional push
Set
notificationUrlto the channel's webhook URL andclientStateto a long random secret. RunrunScheduled()either way: it creates and renews the subscription and sweeps the mailbox, since Graph can drop notifications.
Configure
microsoft365Channel({
id: "email",
tenantId: process.env.MS_TENANT_ID!,
clientId: process.env.MS_CLIENT_ID!,
clientSecret: process.env.MS_CLIENT_SECRET!,
mailbox: "support@acme.com",
notificationUrl: "https://acme.com/api/webhooks/support/email",
clientState: process.env.MS_CLIENT_STATE!,
})Options
| Name | Type | Description |
|---|---|---|
id* | string | Stable channel id, stored on every ticket and used in the webhook URL. Never change it. |
tenantId* | string | Directory (tenant) id of the tenant that owns the mailbox. |
clientId* | string | Application (client) id. |
clientSecret* | string | The app's client secret. |
mailbox* | string | The user or shared mailbox to read and send from. |
notificationUrl | string | Public webhook URL for change notifications. Omit to poll only. |
clientState | string | Secret Graph echoes in every notification. Required with notificationUrl. |
baseUrl | string | Microsoft Graph base URL, for national clouds. |
Behaviour
- Replies your team sends from Outlook are recorded on the ticket from Sent Items. Junk Email is never read.
- Mail goes out as the mailbox itself, so it uses the mailbox's display name rather than
fromName.