Introducing a new way to review your PRs.

Read the announcement

getnao / nao

👾 nao is the #1 open source agentic BI. (1) Create context with nao-core cli, (2) deploy nao chat interface for everyone

View on GitHub

23 documents · Updated Nov 23, 2026

docs / messaging-channel-integrations

Messaging channel integrations

Messaging channel integrations let project members use the product’s agent through Slack, Discord, Microsoft Teams, Mattermost, Telegram, and WhatsApp. Each adapter translates channel events into a project chat, applies the channel’s identity and reply rules, and sends the agent’s answer back in a format that the channel supports.

See the automations and integrations page for the wider integration model and automation workflows for non-conversational message delivery.

Shared messaging model

Message lifecycle

Every adapter follows the same product flow after it accepts a channel message. The adapter identifies the project and sender, checks access, attaches the message to an existing channel conversation or starts one, and runs the messaging agent. The answer is then rendered through the channel’s native text, card, file, or image features.

The flow below shows the shared boundary between channel-specific behavior and the common agent system.

flowchart LR
    E[Channel event] --> V[Verify channel credentials]
    V --> R[Apply reply policy]
    R --> I[Resolve sender and project access]
    I --> C[Load or create project chat]
    C --> A[Run messaging agent]
    A --> O[Render answer in channel]
    O --> S[Persist conversation and feedback]

Channel rules decide whether an event reaches this flow. For example, a public thread may require a mention or an existing chat. Direct messages usually have a broader reply scope. The agent itself remains the same product capability across channels, while the output shape changes to match the channel.

References: apps/…/slack.ts• L469-494 apps/…/discord.ts• L195-262 apps/…/teams.ts• L105-120 apps/…/mattermost.ts• L128-157 apps/…/telegram.ts• L82-121 apps/…/whatsapp.ts• L106-125

Channel configuration

Each project stores the credentials and behavior needed by its enabled adapters. An adapter starts only when its required credentials are present. A selected model can be set per channel, so a channel can use a different agent model without changing the project’s main chat experience.

ChannelRequired channel credentialsMain channel behavior
SlackBot token plus a signing secret for webhooks or an app token for Socket ModeConfigurable thread reply policy and optional user auto-creation
DiscordBot token and application ID, with a public key for interaction verificationMention, direct-message, and selected-channel controls
Microsoft TeamsApp ID, app password, and tenant IDTenant-aware identity lookup through Microsoft Graph
MattermostMattermost base URL and bot tokenOptional signed callbacks for stop controls and feedback
TelegramBot tokenWebhook message handling with project linking codes
WhatsAppAccess token, app secret, phone number ID, and verify tokenWebhook handling with persisted phone-account links

References: apps/…/project-slack-config.queries.ts• L22-50 apps/…/project-discord-config.queries.ts• L86-103 apps/…/project-teams-config.queries.ts• L22-37 apps/…/project-mattermost-config.queries.ts• L78-94 apps/…/project-telegram-config.queries.ts• L22-35 apps/…/project-whatsapp-config.queries.ts• L22-43

Authentication and event intake

Slack adapter

The Slack adapter supports two event transports. Webhook mode receives signed HTTP events. Socket Mode receives events over Slack’s socket connection and forwards them through the same event handling path, so slash commands and interactive actions keep the same behavior in both modes.

Slack message access uses the sender’s Slack email to find a product user. Projects may allow auto-creation for approved email domains. Otherwise the sender must already belong to the project with an allowed role.

Slack reply behavior is controlled by two modes:

  • mention replies to new mentions and does not answer later thread messages unless they mention the bot.
  • thread subscribes to a new thread and answers later human messages in that thread.

The adapter removes the bot mention before it sends the question to the agent. It also claims each message once so duplicate Slack deliveries do not create duplicate answers.

References: apps/…/slack.ts• L153-178 apps/…/slack.ts• L189-203 apps/…/slack.ts• L469-494 apps/…/slack.ts• L593-663 apps/…/slack-socket-bridge.ts• L31-43 apps/…/slack-reply-policy.ts• L10-14

Discord adapter

The Discord adapter receives ordinary messages through a gateway and receives interactions such as buttons through the HTTP webhook. The gateway is kept alive and restarted when it ends. The webhook handles interaction events for the already running project adapter.

Discord does not expose member email addresses. The adapter therefore links a Discord user to a product account with a short-lived account link or a project linking command. A configured fallback user can provide the project identity when the message has no linked sender. The linked account must have project access before the agent runs.

In a server channel, an explicit bot or configured role mention starts a conversation. Later messages are accepted when they belong to an existing channel thread. Direct messages can start a conversation without a mention. Bot messages and the adapter’s own messages are ignored.

References: apps/…/discord.ts• L117-161 apps/…/discord.ts• L195-243 apps/…/discord.ts• L316-408 apps/…/discord-helpers.ts• L104-116

Microsoft Teams adapter

The Teams adapter receives Bot Framework webhook events and uses the configured app credentials to build a Microsoft Graph client. It reads the sender’s Azure Active Directory object ID and tenant ID, then resolves the sender’s email in that tenant.

The sender must map to an existing product user and have access to the project. In a channel, a new message must mention @nao; in a direct message, any new message is accepted. Once the adapter subscribes to a thread, later messages in that thread continue the same project chat.

References: apps/…/teams.ts• L84-141 apps/…/teams.ts• L194-247 apps/…/project-teams-config.queries.ts• L22-37

Mattermost adapter

The Mattermost adapter connects to a configured Mattermost server with a bot token. It receives new messages, mentions, subscribed thread messages, and reactions through the adapter webhook path. Interactive buttons are optional and use a project-specific signed callback token.

Mattermost identifies a sender by Mattermost user ID and resolves the sender’s email through a short-lived cache or a profile lookup. If that match is not available, the sender can use a project linking command. In public channels, a mention or an existing project chat is needed. Direct messages can start a chat without a mention.

References: apps/…/mattermost.ts• L89-157 apps/…/mattermost.ts• L159-250 apps/…/mattermost.ts• L324-395 apps/…/mattermost-helpers.ts• L70-80

Telegram adapter

The Telegram adapter receives webhook events for new messages and mentions. It treats /login <code> as an account-link action and routes all other messages into the project chat flow. A Telegram user must link the Telegram identity to a product account before the adapter accepts questions.

The link is held by the running Telegram service. If the service loses that state, the user must link again. After access is confirmed, a Telegram thread maps to one project chat and later messages continue that context.

References: apps/…/telegram.ts• L48-121 apps/…/telegram.ts• L179-240 apps/…/project-telegram-config.queries.ts• L22-35

WhatsApp adapter

The WhatsApp adapter uses the provider webhook for both verification requests and incoming messages. It marks received messages as read and sends a typing signal before it starts work. It supports /login <code> for account linking and /new for a fresh conversation.

WhatsApp links a phone identity to one product user in the project database. The link is checked for conflicts, so one WhatsApp account cannot silently move between users. The adapter also accepts image attachments and can turn voice notes into text when project transcription is enabled.

References: apps/…/whatsapp.ts• L8-37 apps/…/whatsapp.ts• L64-165 apps/…/whatsapp.ts• L167-245 apps/…/whatsapp.ts• L263-409 apps/…/project-whatsapp-config.queries.ts• L22-43

Reply and outbound behavior

Streaming answers

The adapters run the same messaging agent but choose different delivery methods. Channels that support message edits show a placeholder first, update it while the agent streams, and replace it with the final answer. WhatsApp sends the completed text after the stream because its adapter path treats the stream as an internal build step.

Tool activity is summarized for chat users rather than exposed as raw agent events. Query results can become tables. Charts and maps become native images when the channel supports them, or a link back to the product when it does not. The product chat URL is the durable place to read content that does not fit a channel’s limits.

References: apps/…/slack.ts• L629-645 apps/…/discord.ts• L264-314 apps/…/teams.ts• L152-191 apps/…/mattermost.ts• L271-321 apps/…/telegram.ts• L133-173 apps/…/whatsapp.ts• L446-463

Interactive controls

Stop controls and feedback actions are part of the outbound contract when a channel supports them. A stop action asks the active agent to stop. Feedback actions map channel buttons or reactions to the stored assistant message, so user ratings remain tied to the product conversation.

ChannelStop behaviorFeedback behavior
SlackCard action stops the active streamCard actions record positive or negative feedback, with a modal for negative feedback
DiscordMessage component stops the active streamThumbs-up and thumbs-down reactions record or remove feedback
Microsoft TeamsCard action stops the active streamCard actions record positive or negative feedback
MattermostOptional signed callback stops the active streamSigned post metadata ties reactions to the assistant message
TelegramCard action stops the active streamCard actions record positive or negative feedback
WhatsAppNo channel stop or feedback flow is registeredNo channel feedback flow is registered

References: apps/…/slack.ts• L496-567 apps/…/discord.ts• L205-223 apps/…/discord.ts• L904-966 apps/…/teams.ts• L117-140 apps/…/mattermost.ts• L138-155 apps/…/mattermost.ts• L864-980 apps/…/telegram.ts• L98-121 apps/…/whatsapp.ts• L106-113

Outbound messaging

Outbound messages preserve the conversation’s channel and thread identity. Slack can post text, cards, files, charts, maps, and direct messages. Discord and Mattermost edit an answer post and attach overflow or media when needed. Teams and Telegram use cards and follow-up media posts. WhatsApp sends final text, chart images, and map links as separate messages.

Channel limits shape the fallback behavior. Discord truncates long answers and attaches the full Markdown answer. Mattermost truncates to its post limit. Slack falls back from a rejected rich card to plain text and links the user to the full answer when its payload is too large. These fallbacks protect the answer even when the channel cannot display the preferred format.

References: apps/…/slack.ts• L217-256 apps/…/slack.ts• L364-439 apps/…/discord.ts• L535-604 apps/…/mattermost.ts• L527-551 apps/…/telegram.ts• L268-279 apps/…/whatsapp.ts• L450-463 apps/…/whatsapp.ts• L610-646

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep each channel’s stored thread key aligned with the chat lookup and chat creation paths. A mismatch starts a new conversation instead of continuing the user’s context.
  • Keep webhook and gateway authentication requirements aligned with the project configuration checks. Slack transport changes must preserve the correct signing or app token path.
  • Keep account-link rules aligned with the provider identity field. Discord, Mattermost, Telegram, and WhatsApp do not use the same identity store.
  • Keep channel reply filters aligned with mention removal. A provider can accept an event but still send the wrong prompt if its mention syntax is not stripped.
  • Keep rich output fallbacks within provider message limits. A new card or media type must have a text or product-link fallback where the channel cannot render it.
  • Keep interactive action metadata tied to the project and assistant message. Unsigned or stale callbacks must not change agent state or feedback.

Important failure modes

TriggerConsequenceGuard
Missing Slack bot token, signing secret, or Socket Mode app tokenThe project has no usable Slack adapterConfiguration loading rejects incomplete transport credentials
Discord user has no persisted linkThe question is not run for that userThe adapter sends an account-link flow or login prompt
Teams identity or tenant cannot be resolvedThe message cannot be mapped to a project userTenant-aware Graph lookup must succeed before access checks
Mattermost callback token is invalidStop or interactive actions are ignoredThe route verifies a project-and-post signed secret before dispatch
Telegram service restarts after a user linksThe user must link again before asking a questionThe adapter treats missing in-memory identity state as unlinked
WhatsApp link points to a removed userThe request is rejected and the stale link is deletedUser lookup validates and removes invalid persisted links
Answer exceeds a channel’s message limitRich output may fail or lose contentAdapters truncate, attach, use plain text, or link to the full product answer

Key files

FileWhy to read it
apps/…/slack.tsShows Slack identity checks, reply policy, streaming cards, files, and actions.
apps/…/discord.tsShows gateway intake, account linking, mention rules, answer editing, and reaction feedback.
apps/…/teams.tsShows Teams webhook intake, tenant identity lookup, cards, and thread context.
apps/…/mattermost.tsShows Mattermost identity linking, reply filtering, signed actions, and reaction feedback.
apps/…/telegram.tsShows Telegram linking, webhook messages, card updates, and media output.
apps/…/whatsapp.tsShows WhatsApp verification, persisted linking, media input, and final-message delivery.
apps/…/slack-socket-bridge.tsShows how Slack Socket Mode events share the webhook adapter path.
apps/…/markdown-messaging.tsDefines the common direct-message, mention, thread, and bot-message handling policy used by Discord and Mattermost.
apps/…/project-slack-config.queries.tsDefines Slack transport and reply configuration requirements.
apps/…/whatsapp.tsIllustrates provider webhook verification and event forwarding for WhatsApp.