Framework
An inbound email and a message sent from a business chat service can reach the same internal inbox. Follow an inbound message through normalization and then follow a reply out through the connected account that should send it.
The Communications Hub (communication_channels) bridges external chat and email channels (Slack, WhatsApp, Gmail, IMAP+SMTP) into the Messages module, and routes mobile push through the same ChannelAdapter contract. Each provider ships as a separate workspace package; the hub itself stays adapter-agnostic.
Three message providers ship today, all channelScope: 'user':
@open-mercato/channel-imap – credential-based IMAP polling + SMTP send@open-mercato/channel-gmail – Gmail OAuth2 + History API polling + gmail.users.messages.send@open-mercato/channel-discord – Discord bot: REST outbound, real-time inbound over a
provider-owned Gateway (WebSocket) worker, and an Ed25519-signed Interactions endpoint. The first
non-email provider, and the first with capabilities.recipientFormat: 'provider-native' and
realtimePush: true. See Set up Discord
for the operator runbook.Three push providers ship today, all channelType: 'push' and channelScope: 'tenant' – one credential serves every device in the tenant, so they are connected through the admin-gated tenant connect route rather than the per-user one:
@open-mercato/channel-fcm – Firebase Cloud Messaging (Android and iOS, the latter relayed via APNs)@open-mercato/channel-apns – Apple Push Notification service, directly@open-mercato/channel-expo – Expo push service (Android and iOS)Push delivery itself is owned by the push_notifications module; these packages hold only the provider SDKs and their message builders. Push credentials are tenant-scoped (channelScope: 'tenant'), so they are connected through POST /api/communication_channels/channels/connect/tenant-credentials and the per-user connect route refuses them. See Push Notifications and the getting-started tutorial.
For the end-user perspective see the Communication Channels user guide.
packages/core/src/modules/communication_channels/packages/channel-{imap,gmail}/ (email), packages/channel-discord/ (chat) and packages/channel-{fcm,apns,expo}/ (push){ id: 'communication_channels', from: '@open-mercato/core' } plus one entry per provider you want active in apps/mercato/src/modules.ts. The module declares requires: ['progress'] – its import-history worker resolves progressService from DI – so { id: 'progress', from: '@open-mercato/core' } must be enabled too, or yarn generate fails with "Module dependency check failed"..ai/specs/implemented/SPEC-045d-communication-notification-hubs.md (hub contract) and .ai/specs/2026-05-21-email-integration-foundation.md (email providers + per-user surfaces). ┌──────────────────────────────────────────────┐
│ Communications Hub (communication_channels) │
│ │
┌──────────┤ ChannelAdapter registry (process-wide) │──────────┐
│ │ CommunicationChannel + ExternalConversation │ │
│ │ ExternalMessage + MessageChannelLink │ │
│ │ ChannelThreadMapping + MessageReaction │ │
│ └──────────────────────────────────────────────┘ │
▼ ▼
┌──────────┐ ┌──────────┐ ┌────────┐
│ channel- │ │ channel- │ … (future: channel-slack, │ Messages │
│ imap │ │ gmail │ channel-whatsapp, etc.) │ module │
│ (basic │ │ (OAuth) │ └────────┘
│ auth) │ │ │
└──────────┘ └──────────┘
Each provider exports a ChannelAdapter from @open-mercato/core/modules/communication_channels/lib/adapter. The hub's registry validates capability/method consistency at registration time (so an adapter that declares capabilities.deleteMessage: true without implementing deleteMessage() throws on boot).
Phase 0 of the email integration spec added additive columns to CommunicationChannel:
| Column | Purpose |
|---|---|
user_id (uuid, nullable) | Owns this channel (NULL = tenant-shared) |
is_primary (boolean) | True for the user's default outbound channel; enforced by a partial unique index |
poll_interval_seconds (int, nullable) | Per-channel override of the platform default poll cadence |
last_polled_at (timestamptz, nullable) | Stamped by the poll worker on every tick |
status (text) | connected / requires_reauth / disconnected / error |
last_error (text, nullable) | Classified error string for diagnostics |
Plus an additive column on integration_credentials:
| Column | Purpose |
|---|---|
user_id (uuid, nullable) | Identifies per-user credential rows so tenant-shared and per-user blobs can coexist |
Cross-module references use EntityExtension declarations in data/extensions.ts (no direct ORM relationships across module boundaries).
Compose (Messages)
│
▼
messages.message.sent event
│
▼
subscribers/outbound-bridge.ts (re-fetches the Message by ID — no payload coupling)
│
▼
deliver-outbound-message command
│
▼
ChannelAdapter.sendMessage ── refreshCredentials() if access token near expiry
│
▼
ExternalMessage + MessageChannelLink rows written
Version availability. The polling mechanism below is present in v0.10.0. The “Automatic sync is off” profile warning and the CRM preset scheduling change described next are development-branch additions after v0.10.0.
Polling needs the scheduler module. The hub registers its poll tick and the Gmail watch renewal from seedDefaults and onOrganizationCreated, and skips both when schedulerService is not available – mail then arrives only on a manual "Poll now", and the profile page "My communication channels" shows an "Automatic sync is off" warning while any connected channel relies on polling and the organization's poll-tick schedule is missing, disabled, or deleted. The crm starter preset enables scheduler; an app that enables it later must run yarn mercato seed:defaults --module communication_channels once so existing organizations get their schedules, and yarn mercato auth sync-role-acls so existing roles get the scheduler features.
@open-mercato/scheduler "poll-tick" (every OM_HUB_POLL_SCHEDULER_TICK_SECONDS, 60 s by default)
│ enqueues channels whose poll interval is due (OM_HUB_POLL_DEFAULT_SECONDS, 5 minutes by default)
▼
poll-channel worker (per channel)
│
▼
ChannelAdapter.fetchHistory ── reads previous cursor from channelState
│
▼
ingest-inbound-message command
│
▼
ExternalMessage written + Message materialised into the unified inbox
│
▼
communication_channels.message.received event + notification
Phase 4 of the email integration spec added two hub-side guards (packages/core/src/modules/communication_channels/lib/mutation-guards.ts):
guardChannelDelete – blocks delete when unread inbound messages remain on the channel. force: true bypasses, for admin offboarding workflows.guardOutboundCreate – maps status='requires_reauth' / 'disconnected' to a 422 with fieldErrors.channelId. Wired into POST /api/communication_channels/send-as-user.OAuth providers (Gmail) need their tenant-level OAuth client config – clientId and clientSecret – every time a per-user access token is refreshed. The hub resolves this once before delegating to the adapter via the RefreshCredentialsInput.oauthClient field:
export interface RefreshCredentialsInput {
channelId: string
/** Per-user credential blob (accessToken, refreshToken, expiresAt, …) */
credentials: Record<string, unknown>
scope: TenantScope
/**
* Tenant-level OAuth client config resolved by the hub from
* `integration_credentials.scope = channel_<providerKey>`.
*
* - OAuth providers (Gmail): MUST read clientId / clientSecret from this field.
* - Static-credential providers (IMAP, WhatsApp): ignore.
*/
oauthClient?: OAuthClientConfig
}
export interface OAuthClientConfig {
clientId: string
clientSecret?: string
/** OAuth directory/tenant id for providers that require one (provider-specific). */
tenantId?: string
/** Optional pre-resolved scopes list. */
scopes?: string[]
}
The hub's refreshCredentialsIfNeeded helper resolves channel_<providerKey> via IntegrationCredentialsService.resolve(...) and passes the result through. Provider adapters that implement OAuth refresh MUST read clientId / clientSecret from input.oauthClient – see packages/channel-gmail/.../lib/adapter.ts:refreshCredentials for the reference implementation.
When the helper cannot resolve the OAuth client (missing channel_<provider> integration credential row, or credentialsService not registered), oauthClient is left undefined. The Gmail adapter then fails refresh with a clear error and the channel flips to status='requires_reauth' so the operator-visible notification fires.
Shipped 2026-05-27. See .ai/specs/implemented/2026-05-27-email-integration-inbound-reliability-and-threading.md for the full design rationale.
Outbound delivery now injects a per-thread HMAC token (om_<base64url>_<base64url>) into both:
<[email protected]> Message-ID appended to the References header (RFC 6761 reserved TLD – guaranteed to round-trip through compliant MTAs).<span> (HTML emails) and a bracketed marker (plain-text) at the bottom of the body. Survives mail clients that strip References headers.Inbound ingestion runs a five-strategy matcher in priority order before falling back to a new thread:
| Strategy | Confidence | When it fires |
|---|---|---|
token-references | high | Reply preserves the om_* Message-ID in References / In-Reply-To. Most common. |
token-body | high | Reply quoted our outbound body; the hidden footer survived. |
jwz-headers | medium | Standard JWZ algorithm against In-Reply-To / References pointing at our outbound Message-Id. Pre-token outbounds. |
subject-participants | low | Normalized subject match (Re:, Fwd:, [EXTERNAL] stripped) + participant set overlap. Last-ditch. |
| (none) | – | New thread. |
MessageChannelLink.channelMetadata.threadMatchStrategy + threadMatchConfidence are persisted on every inbound for observability.
A freshly-connected IMAP channel fetches zero historical messages – fetchHistory records UIDVALIDITY + UIDNEXT and returns immediately. From the next tick onward, the worker does UID FETCH previousUidNext:* capped at OM_CHANNEL_IMAP_HARD_CAP_PER_POLL (default 200). When more remain, hasMore: true triggers immediate re-enqueue without waiting for the next scheduler tick. UIDVALIDITY mismatch (mailbox rename / recreate) re-bootstraps rather than re-syncing the whole inbox.
This eliminates the "we can't scan a new user's 1M-message inbox on connect" failure mode by construction. Backlog import is opt-in via the operator-triggered flow below.
poll-channel.ts advances the channel cursor (channel_state.uidNext) per successfully-ingested message. A transient ingest failure (DB blip, network reset) aborts the loop without advancing – the next tick re-fetches the same UIDs and idempotency on (channel_id, external_message_id) skips already-ingested messages. A permanent failure (malformed MIME, schema violation) writes the raw payload to channel_ingest_dead_letters (encrypted) and advances the cursor anyway so the bad blob never re-stalls the channel.
poll-tick.ts enumerates two pools: (a) status='connected' channels due for normal polling, (b) status='error' channels whose lastFailureAt is older than OM_CHANNEL_AUTO_RECOVER_MINUTES. A successful poll in pool (b) flips status back to connected automatically – operators no longer have to manually reconnect after a transient outage.
The POST /api/communication_channels/channels/<id>/import-history route (gated by the communication_channels.channel.import_history ACL feature) creates a ProgressJob and enqueues a channel-import-history worker job (concurrency 1) that calls adapter.importHistory({ sinceDays, contactEmails?, maxMessages, cursor }) in a pagination loop:
| Field | Range | Purpose |
|---|---|---|
sinceDays | 1..365 | Server-side SEARCH SINCE window. |
contactEmails | optional, up to 1000 | Server-side OR FROM … filter, chunked to ≤30 senders per SEARCH to keep the IMAP tag buffer bounded. |
maxMessages | 1..5000 | Hard cap across all pages. Worker stops paging as soon as the cap is hit. |
A 429 is returned if another import is in-flight for the same channel (active-jobs scan, plus the worker's concurrency: 1 is the second line of defence). Progress streams to the existing ProgressTopBar via ProgressService.updateProgress(...). Adapter contract is additive optional – adapters that don't implement importHistory() get a 400 envelope back from the route (backlog import is IMAP-only; the Gmail adapter does not implement importHistory).
The UI lives on /backend/profile/communication-channels as a per-row "Import history" button → modal dialog (Cmd/Ctrl+Enter submits, Escape cancels). On success the dialog calls router.refresh() instead of window.location.reload() – preserves scroll position and avoids the flash that a full reload causes.
Shipped 2026-05-27. See .ai/specs/implemented/2026-05-27-email-integration-inbound-reliability-and-threading.md for the full design rationale.
Spec B established the polling foundation: 60-second cadence for IMAP and Gmail alike. Spec C replaces the 60s polling cadence for Gmail with native push delivery, dropping inbound latency from ≤60s to 5–15s typical while leaving 30-minute polling as a belt-and-suspenders fallback.
Three optional methods on ChannelAdapter:
registerPush(input): Promise<PushRegistration> – Gmail: calls users.watch with the operator-configured Pub/Sub topic.unregisterPush(input): Promise<void> – Counterpart for disconnect / reauth. Gmail: users.stop. Idempotent on 404.applyPushNotification(input): Promise<HistoryPage> – Turns a verified inbound notification into the same HistoryPage shape fetchHistory returns. Gmail: walks history.list, delegating to fetchHistory so the pagination + cursor-recovery logic stays in one place.Adapters that don't implement these methods (IMAP, chat providers) stay on Spec B's polling.
[email protected] publisher, attach a push subscription to the topic pointing at https://<your-host>/api/communication_channels/webhooks/gmail with a service-account identity. Set OM_GMAIL_PUBSUB_TOPIC, OM_GMAIL_PUBSUB_AUDIENCE, OM_GMAIL_PUBSUB_SERVICE_ACCOUNT_EMAIL.adapter.registerPush(...), which invokes gmail.users.watch. The returned historyId + watchExpirationMs are persisted to channelState.{ emailAddress, historyId } to the topic on every mailbox change (rate-capped at 1/s/user).lib/gmail-pubsub-jwt.ts verifies the RS256 signature, aud claim, and email claim.communication-channels-gmail-history-sync job per matching channel (we look up across all tenants by emailAddress and dispatch per-tenant – same emailAddress connected to multiple tenants is supported).gmail-history-sync worker calls adapter.applyPushNotification(...) (which walks history.list from the stored cursor) and feeds each new message through ingest-inbound-message. Cursor advances per-message commit (Spec B contract).gmail-renew-watch queue, registered per-org in setup.ts) finds channels within OM_PUSH_RENEWAL_GMAIL_LEAD_HOURS (default 24h) of expiry and triggers pushRegister(...) again.pollIntervalSeconds automatically flips from 60 to 1800 (30 min) when pushStatus='active' is persisted by registerPush. If push fails (e.g. the Gmail Pub/Sub topic is misconfigured) the channel keeps polling at 60s, so no message is ever lost. The pushStatus='failed' channel surfaces in the operator UI with a "Re-register push" button calling POST /api/communication_channels/channels/<id>/push/register.
@open-mercato/channel-gmail)https://www.googleapis.com/auth/gmail.modify (or the narrower gmail.send + gmail.readonly combo if you prefer), plus userinfo.email and userinfo.profile.https://<your-host>/api/communication_channels/oauth/gmail/callback
for every environment you run (production, staging, local dev).In Backend → Integrations → Gmail add the client ID and secret. Scopes leave blank for defaults, or override with a comma-separated list matching what you configured in the consent screen.
The credentials are stored encrypted on IntegrationCredentials and resolved at runtime when a user clicks Connect Gmail. Users never see the client secret.
When you're ready to onboard more than 100 users, submit the OAuth app for verification. The hub keeps working without verification while you're under that limit and inside Workspace test-user lists.
@open-mercato/channel-imap)No tenant setup required. The integrations admin page lets you toggle the provider on or off; individual users provide their own host/port/credentials when they connect.
The hub reads a small set of env vars; most have sensible defaults, but a few must be set explicitly – production-required ones are called out in the rows below.
| Variable | Default | Purpose |
|---|---|---|
OM_HUB_OAUTH_STATE_KEY | falls back to KMS_MASTER_KEY, then to JWT_SECRET (non-production only) | AES-256-GCM key used to encrypt the OAuth state cookie. Required in production – set this or KMS_MASTER_KEY, or the per-user OAuth connect flow fails closed. Rotate this on a schedule – see runbook below. |
OM_HUB_OAUTH_STATE_TTL_SECONDS | 300 (5 minutes) | TTL on the state cookie. OAuth callbacks older than this are rejected. |
OM_HUB_POLL_DEFAULT_SECONDS | 300 (5 minutes) | Default poll cadence applied to channels that don't set poll_interval_seconds. |
OM_HUB_POLL_CONCURRENCY | 10 | Max parallel poll-channel worker jobs per process. Bound by your DB connection pool. |
OM_HUB_OUTBOUND_RETRY_MAX | 5 | Outbound delivery retries before marking the Message delivery_failed. |
OM_HUB_POLL_SCHEDULER_TICK_SECONDS | 60 | Interval between poll-tick scheduler runs that enumerate due channels and fan out to per-channel poll jobs. Lower-bounded at 10 s. |
OM_CHANNEL_IMAP_HARD_CAP_PER_POLL | 200 | Maximum number of IMAP UIDs fetched per fetchHistory page. When more remain, the adapter sets hasMore: true and the hub re-enqueues immediately. Tune lower if a single page's wall-clock budget is too tight; never set above ~500 (DB transaction size). |
OM_CHANNEL_AUTO_RECOVER_MINUTES | 30 | Spec B § B5 auto-recovery sweep window. poll-tick re-enqueues status='error' channels whose lastFailureAt is older than this. Set 0 in tests to force immediate retry. |
OM_THREAD_TOKEN_SECRET | derived from KMS_MASTER_KEY via HKDF | HMAC key used by Spec B's lib/thread-token.ts to mint per-thread om_* tokens injected into outbound References headers + a hidden body footer. Rotating invalidates all existing tokens (older threads fall back to JWZ + subject-participants strategies – no data loss). |
OM_GMAIL_PUBSUB_TOPIC | (none – required for Gmail push) | Fully-qualified Pub/Sub topic, e.g. projects/openmercato-prod/topics/gmail-inbound. Passed to gmail.users.watch. |
OM_GMAIL_PUBSUB_AUDIENCE | (none – required for Gmail push) | Expected aud claim in the Pub/Sub-signed JWT. Set this to the webhook URL or a stable identifier configured on the Pub/Sub push subscription. |
OM_GMAIL_PUBSUB_SERVICE_ACCOUNT_EMAIL | (none – required for Gmail push) | Expected email claim in the Pub/Sub JWT. Typically the service account configured on the push subscription (NOT [email protected] – that's the publisher into the topic). |
OM_PUSH_RENEWAL_GMAIL_LEAD_HOURS | 24 | Renewal lead time for gmail.users.watch. Lower means we renew earlier; higher means we cut closer to the 7-day expiration. |
OM_IMPORT_HISTORY_MAX_SINCE_DAYS | 3650 (10 years) | Deployment-wide ceiling on the operator-triggered "Import History" sinceDays field. Can only raise the ceiling, never below the 30-day default. Per-provider ceilings (e.g. IMAP's 365) still apply on top of this. |
OM_IMPORT_HISTORY_MAX_MESSAGES | 50000 | Deployment-wide ceiling on the operator-triggered "Import History" maxMessages field. Can only raise the ceiling, never below the 1000-message default. Per-provider ceilings (e.g. IMAP's 5000) still apply on top of this. |
yarn db:migrate runs the hub's migration plus the per-user-columns migration (Migration20260526154135_communication_channels).yarn mercato auth sync-role-acls so the new communication_channels.* features (including communication_channels.connect_user_channel) are granted to the appropriate roles.yarn mercato configs cache structural --all-tenants. Mandatory after any modules.ts change that adds a provider (slices 3e/3f enable channel_imap and channel_gmail).OM_HUB_OAUTH_STATE_KEY – required in production unless KMS_MASTER_KEY is set; set it explicitly even when KMS_MASTER_KEY is present if you want to rotate the state-cookie key independently of it.| Task | When | How |
|---|---|---|
| Rotate the OAuth state-cookie key | Every 90 days (recommended), or after any suspected compromise | Set OM_HUB_OAUTH_STATE_KEY to a new random 32-byte base64 value and roll the deploy. In-flight OAuth flows fail with state expired and the user retries – that's expected and safe. |
| Bump a tenant's OAuth client secret | After a provider rotates its credentials | Update the secret in Backend → Integrations → <Provider> for the tenant. No restart required; the next refresh-token call picks it up. |
| Force a poll outside the 5-minute cadence | User reports "I sent mail and don't see it" | Click Refresh on the channel row in the user's profile page, or call POST /api/communication_channels/channels/<id>/test-send for end-to-end. |
| Purge a disconnected user's channels | When a user leaves the org | The auth.user.deleted cascade subscriber handles it automatically (see Phase 4 implementation status in the email integration spec). Manually: hit the disconnect command for each channel. |
Tip · Full walkthrough
Building on the Communications Hub covers this end-to-end – the adapter contract, the capability rules, fail-closed webhook verification, the worker pattern for transports that are not webhooks, and tenant-scoped provider state. The steps below are the short version.
The hub deliberately stays adapter-agnostic. To add another email provider (e.g. Yahoo, ProtonMail Bridge variant), follow the same shape as the shipping packages:
mkdir packages/channel-<provider> and copy the build/watch/jest/tsconfig templates from packages/channel-imap.ChannelAdapter in src/modules/channel_<provider>/lib/adapter.ts.src/modules/channel_<provider>/setup.ts via registerChannelAdapter(getAdapter()).{ id: 'channel_<provider>', from: '@open-mercato/channel-<provider>' } to apps/mercato/src/modules.ts.yarn generate && yarn build:packages && yarn test, then yarn mercato configs cache structural --all-tenants.The hub's webhook router, OAuth router, send-as-user route, and admin UI auto-discover the new provider by providerKey; no hub changes required.
TenantDataEncryptionService (AES-256-GCM, per-tenant DEKs). The adapter receives plaintext only inside the request scope; no SQL probe leaks plaintext.OM_HUB_OAUTH_STATE_KEY, bound to the initiating user's id. Catches replays + replay-across-users.crypto.randomBytes(64). The verifier is persisted only in the state cookie – never logged or stored server-side.packages/core/src/modules/communication_channels/lib/sanitize-channel-html.ts before dangerouslySetInnerHTML. Allowlist tuned for email + chat; strips <script>, <iframe>, event handlers, and javascript: / non-image data: URLs.verifyWebhook. Routes that find no adapter for the providerKey return 404, never 5xx.communication_channels.view / .manage / .react / .assign / .connect_user_channel / .admin. Page metadata uses requireFeatures (never requireRoles).Each slice ships its own module-local integration specs under __integration__/:
| Test | Location | What it covers |
|---|---|---|
TC-045D-001..006 | hub | Hub schema + adapter contract + entity extensions |
TC-CHANNEL-EMAIL-HUB-001..003 | hub | Per-user channel API contract + profile page |
TC-CHANNEL-EMAIL-001..003 | channel-imap | IMAP provider registration + webhook no-op + profile page |
TC-CHANNEL-EMAIL-006..008 | channel-gmail | Gmail OAuth router + webhook no-op + profile page |
TC-CHANNEL-EMAIL-014..020 | hub | Phase 4 cross-provider scenarios: primary swap, admin RBAC, tenant OAuth override, disconnect, send-as-user guard, user-deleted cascade, rich-content widget |
TC-CHANNEL-EMAIL-HUB-007..008 | hub | send-as-user attachments: bytes delivered to the adapter, caller-written refs dropped, refusals (no file sharing, wrong owner, other organization, type not allowed) |
Run with:
yarn test:integration # full suite
OM_INTEGRATION_MODULES=communication_channels,channel-imap,channel-gmail \
yarn test:integration # email-foundation slice only
A ChannelAdapter is the only thing a provider package must expose. The complete contract lives at packages/core/src/modules/communication_channels/lib/adapter.ts. Methods are split into required core, optional extensions, and OAuth helpers – providers only implement the methods that match their declared capabilities (the registry validates consistency on registration).
sendMessage(input) – outbound delivery, returns { externalMessageId, status, … }verifyWebhook(input) – signature verification on inbound POSTs; polling-only providers return eventType: 'other'getStatus(input) – best-effort delivery status for a previously-sent messageconvertOutbound(input) – hub-canonical body → provider-native shapenormalizeInbound(raw) – provider-native payload → NormalizedInboundMessagecapabilities – declares feature support; validated against implemented methodscapabilities.recipientFormat tells the hub what an outbound recipient looks like for this provider:
| Value | Hub validation | Use for |
|---|---|---|
'email' (default when omitted) | Full email-address validation | Email providers – Gmail, IMAP |
'provider-native' | Length plus transport safety only – the recipient must match the allowlist ^[A-Za-z0-9._:@+-]+$ and must not contain .. | Providers addressed by a provider-issued id – e.g. a Discord channel snowflake |
A provider that declares 'provider-native' owns the format check itself and MUST treat the recipient as untrusted input – the hub deliberately does not know what a valid id looks like for your transport.
The transport-safety check is an allowlist, not a denylist, because the recipient reaches adapters that interpolate it into a REST path (Discord posts to /channels/{recipient}/messages). Anything outside the permitted set – path separators, query and fragment markers, whitespace, percent-encoded separators such as %2F, and control bytes – is rejected before your adapter sees it. If your transport's identifiers need a character outside that set, widen the allowlist in lib/outbound-recipient.ts deliberately rather than routing around the check.
fetchHistory(input) – required for polling-based providers (realtimePush: false)validateCredentials(input) – credential-based providers (IMAP)buildOAuthAuthorizeUrl(input) / exchangeOAuthCode(input) / refreshCredentials(input) – OAuth providersdeleteMessage(input) – when capabilities.deleteMessage: truesendReaction(input) / removeReaction(input) / normalizeInboundReaction(raw) – when capabilities.reactions: trueeditMessage(input) – when capabilities.editMessage: trueresolveContact(input) – best-effort CRM contact resolution; returns null when no hint is availablelistSenders(input) – adapter-driven sender enumeration (Slack channels, WhatsApp templates, etc.)See the shipping providers for end-to-end examples:
packages/channel-imap/src/modules/channel_imap/lib/adapter.tspackages/channel-gmail/src/modules/channel_gmail/lib/adapter.tspackages/channel-discord/src/modules/channel_discord/lib/adapter.ts – the non-email
reference: provider-native recipients, realtimePush, a provider-owned Gateway worker instead
of a webhook, and a provider-owned signed route for the interactions handshake