Skip to content

Channels — Slack, Telegram, Discord, WhatsApp, Messenger

Atmosphere Channels bridges your @Agent (or @AiEndpoint) to external messaging platforms. Commands, AI responses, and confirmation flows work identically on every channel — you write the logic once.

ChannelProtocolBot SetupEnv Variable
TelegramBot API webhooks@BotFatherTELEGRAM_BOT_TOKEN
SlackEvents APIapi.slack.com/appsSLACK_BOT_TOKEN
DiscordGateway WebSocketdiscord.com/developersDISCORD_BOT_TOKEN
WhatsAppCloud API webhooksMeta Business SuiteWHATSAPP_ACCESS_TOKEN
MessengerWebhooksMeta for DevelopersMESSENGER_PAGE_TOKEN
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-agent</artifactId>
</dependency>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-channels</artifactId>
</dependency>

Channels activate automatically when credentials are set as environment variables. No channel-specific code is needed.

Open Telegram, message @BotFather, and send:

/newbot

Follow the prompts — choose a name and username. BotFather replies with a token like:

123456789:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw
Terminal window
export TELEGRAM_BOT_TOKEN=123456789:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw
export TELEGRAM_WEBHOOK_SECRET=any-random-string-you-choose

Telegram webhooks require HTTPS. Use Cloudflare Tunnel (free) or ngrok:

Terminal window
# Cloudflare (recommended — no account required for quick tunnels)
cloudflared tunnel --url http://localhost:8080
# Or ngrok
ngrok http 8080

Copy the public URL (e.g. https://your-tunnel.trycloudflare.com).

Terminal window
curl "https://api.telegram.org/bot<YOUR_TOKEN>/setWebhook?url=https://<YOUR_TUNNEL>/webhook/telegram&secret_token=<YOUR_SECRET>"

You should see {"ok":true,"result":true,"description":"Webhook was set"}.

Terminal window
TELEGRAM_BOT_TOKEN=<token> TELEGRAM_WEBHOOK_SECRET=<secret> \
./mvnw spring-boot:run -pl samples/spring-boot-dentist-agent

Message your bot on Telegram — /help, /firstaid, or any question.

Atmosphere verifies every Telegram webhook request using the X-Telegram-Bot-Api-Secret-Token header with constant-time comparison. Requests with missing or invalid secrets are rejected with 403.


Go to api.slack.com/apps and click Create New AppFrom scratch.

Under OAuth & Permissions, add these Bot Token Scopes:

  • chat:write — send messages
  • channels:history — read messages in public channels
  • groups:history — read messages in private channels
  • im:history — read direct messages

Click Install to Workspace and authorize. Copy the Bot User OAuth Token (xoxb-...).

Under Event Subscriptions:

  1. Turn on Enable Events
  2. Set the Request URL to https://<YOUR_TUNNEL>/webhook/slack
  3. Atmosphere automatically responds to Slack’s URL verification challenge
  4. Under Subscribe to bot events, add: message.channels, message.groups, message.im
  5. Click Save Changes

Under Basic InformationApp Credentials, copy the Signing Secret.

Terminal window
export SLACK_BOT_TOKEN=xoxb-your-bot-token
export SLACK_SIGNING_SECRET=your-signing-secret

Atmosphere verifies Slack requests using HMAC-SHA256 with the v0:timestamp:body scheme. Requests older than 5 minutes are rejected to prevent replay attacks.

Add the bot to a channel: type /invite @YourBotName in the channel. Then message it.


Go to discord.com/developers/applications and click New Application.

Under Bot, click Add Bot. Copy the Token.

Under BotPrivileged Gateway Intents, enable:

  • Message Content Intent (required to read message text)
  • Server Members Intent (optional)

Under OAuth2URL Generator:

  • Scopes: bot
  • Bot permissions: Send Messages, Read Message History

Copy the generated URL and open it in your browser to invite the bot.

Terminal window
export DISCORD_BOT_TOKEN=your-discord-bot-token

Discord uses a Gateway WebSocket connection (not HTTP webhooks), so no tunnel is needed. Atmosphere connects to Discord’s gateway automatically, handles heartbeats, sequence tracking, and reconnection.


Go to business.facebook.com and create a business account if you don’t have one.

In Meta for Developers, create a new app of type Business and add the WhatsApp product.

Under WhatsAppAPI Setup:

  • Copy the Phone Number ID
  • Generate a Permanent Access Token (or use the temporary one for testing)
  • Under App SettingsBasic, copy the App Secret

Under WhatsAppConfiguration:

  • Callback URL: https://<YOUR_TUNNEL>/webhook/whatsapp
  • Verify token: any string (used only during initial verification)
  • Subscribe to: messages
Terminal window
export WHATSAPP_PHONE_NUMBER_ID=your-phone-number-id
export WHATSAPP_ACCESS_TOKEN=your-access-token
export WHATSAPP_APP_SECRET=your-app-secret

Atmosphere verifies WhatsApp webhooks using HMAC-SHA256 via the X-Hub-Signature-256 header (Meta platform standard).


You need a Facebook Page for your bot. Create one at facebook.com/pages/create.

In Meta for Developers, create a new app and add the Messenger product.

Under MessengerAccess Tokens, select your Page and generate a token.

Under MessengerWebhooks:

  • Callback URL: https://<YOUR_TUNNEL>/webhook/messenger
  • Verify token: any string
  • Subscribe to: messages
Terminal window
export MESSENGER_PAGE_TOKEN=your-page-access-token
export MESSENGER_APP_SECRET=your-app-secret

Same HMAC-SHA256 scheme as WhatsApp (Meta platform standard).


All channels are configured via environment variables. The Spring Boot configuration maps them:

atmosphere:
packages: com.example.myagent
atmosphere.channels:
telegram:
bot-token: ${TELEGRAM_BOT_TOKEN:}
webhook-secret: ${TELEGRAM_WEBHOOK_SECRET:}
slack:
bot-token: ${SLACK_BOT_TOKEN:}
signing-secret: ${SLACK_SIGNING_SECRET:}
discord:
bot-token: ${DISCORD_BOT_TOKEN:}
whatsapp:
phone-number-id: ${WHATSAPP_PHONE_NUMBER_ID:}
access-token: ${WHATSAPP_ACCESS_TOKEN:}
app-secret: ${WHATSAPP_APP_SECRET:}
messenger:
page-access-token: ${MESSENGER_PAGE_TOKEN:}
app-secret: ${MESSENGER_APP_SECRET:}

Each channel activates only when its credentials are set. You can enable one, some, or all simultaneously.

Atmosphere provides a ChannelFilter chain for processing messages before and after they reach the agent:

  • MessageSplittingFilter — automatically truncates messages that exceed the channel’s max length (4096 for Telegram, 40000 for Slack, 2000 for Discord/Messenger)
  • AuditLoggingFilter — logs all inbound/outbound messages at INFO level

Custom filters implement ChannelFilter and are auto-discovered via Spring Boot component scanning.

SampleChannelsDescription
spring-boot-dentist-agentWeb + Slack + TelegramDr. Molar dental emergency agent with commands and AI tools
spring-boot-channels-chatAll 5 channelsOmnichannel AI chat with all platforms