How erxes/erxes-ai-assistant-gateway works
The product is a shared Discord gateway that maps a guild/channel to a tenant assistant and runtime, then delivers the assistant’s answer back to Discord. Its main flow is Discord interactions or messages → channel binding → runtime request → reply, with separate OAuth installation, Erxes-managed binding, and cron delivery capabilities. The graph reflects documented and indexed connections; unsampled implementation details are not inferred.
Main entry points: messageGateway.ts Message gateway · app.ts HTTP gateway · discordOAuth.ts Discord OAuth · DiscordAssistantBinding.ts Channel bindings
Components 25
Gateway ingress
- HTTP gateway
src/app.ts - Interaction routes
src/routes/discordInteractions.ts - Cron webhook
src/routes/cronWebhook.ts - Discord OAuth
src/routes/discordOAuth.ts
Discord handling
- Discord API client
src/discord/api.ts - Message gateway
src/discord/messageGateway.ts - Channel actions
src/discord/channelActions.ts - Attachment processing
src/discord/attachments.ts - Document extraction
src/discord/documents.ts - Spreadsheet extraction
src/discord/spreadsheets.ts - Presentation extraction
src/discord/presentations.ts - Follow-up delivery
src/routes/discordFollowup.ts
Installation and bindings
- Installation API
src/routes/adminInstallations.ts - Binding API
src/routes/adminBindings.ts - Binding lifecycle
src/discord/bindingLifecycle.ts - OAuth helpers
src/discord/oauth.ts
Assistant and state
- Runtime client
src/openclaw/client.ts - Runtime signing
src/runtime/identity.ts - Channel bindings
src/models/DiscordAssistantBinding.ts - Installations
src/models/DiscordInstallation.ts - OAuth states
src/models/OAuthState.ts - MongoDB connection
src/db/mongo.ts
Other components
- Discord users
- Erxes Admin
- Assistant runtime
Connections 33
- Discord users → HTTP gateway: sends requests
README.md - HTTP gateway → Interaction routes: routes interactions
src/app.ts - HTTP gateway → Discord OAuth: routes OAuth
src/app.ts - HTTP gateway → Installation API: routes API
src/app.ts - HTTP gateway → Binding API: routes API
src/app.ts - HTTP gateway → Cron webhook: routes webhooks
src/app.ts - Interaction routes → Message gateway: dispatches messages
src/routes/discordInteractions.ts - Message gateway → Channel bindings: looks up bindings
src/discord/messageGateway.ts - Message gateway → Runtime client: asks runtime
src/discord/messageGateway.ts - Runtime client → Runtime signing: signs requests
src/openclaw/client.ts - Runtime client → Assistant runtime: sends requests
README.md - Assistant runtime → Runtime client: returns answer
README.md - Message gateway → Discord API client: sends replies
README.md - Message gateway → Attachment processing: checks attachments
src/discord/messageGateway.ts - Message gateway → Document extraction: extracts documents
src/discord/messageGateway.ts - Message gateway → Spreadsheet extraction: extracts spreadsheets
src/discord/messageGateway.ts - Message gateway → Presentation extraction: extracts presentations
src/discord/messageGateway.ts - Binding API → Channel bindings: manages bindings
src/routes/adminBindings.ts - Binding API → Binding lifecycle: delegates lifecycle
src/routes/adminBindings.ts - Installation API → Installations: lists installations
src/routes/adminInstallations.ts - Erxes Admin → Binding API: configures channels
README.md - Erxes Admin → Installation API: manages installs
README.md - Discord OAuth → OAuth helpers: builds install flow
src/routes/discordOAuth.ts - Discord OAuth → OAuth states: stores OAuth state
src/routes/discordOAuth.ts - Discord OAuth → Installations: saves installation
src/routes/discordOAuth.ts - Discord OAuth → Discord API client: exchanges OAuth
src/routes/discordOAuth.ts - Cron webhook → Channel bindings: selects binding
src/routes/cronWebhook.ts - Cron webhook → Discord API client: posts cron result
src/routes/cronWebhook.ts - Follow-up delivery → Message gateway: uses delivery
src/routes/discordFollowup.ts - Follow-up delivery → Channel bindings: loads binding
src/routes/discordFollowup.ts - MongoDB connection → Channel bindings: persists records
- MongoDB connection → Installations: persists records
- MongoDB connection → OAuth states: persists records