Gateway Setup
This guide covers setting up Telegram and Discord gateways for Duragent.
Telegram
1. Create a Bot
- Message @BotFather on Telegram
- Send
/newbotand follow the prompts - Copy the bot token
2. Install the Gateway
cargo install --git https://github.com/giosakti/duragent.git duragent-gateway-telegram
3. Configure
# duragent.yaml
gateways:
external:
- name: telegram
command: duragent-gateway-telegram
env:
TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN}
restart: on_failure
routes:
- match:
gateway: telegram
agent: my-assistant
Note: If you compiled Duragent with
--features gateway-telegram, you can use the built-in config instead:gateways: telegram: enabled: true bot_token: ${TELEGRAM_BOT_TOKEN}
4. Start
export TELEGRAM_BOT_TOKEN=your-token
export OPENROUTER_API_KEY=your-key
duragent serve
Your bot is now live. Send it a message on Telegram.
Telegram Features
- Long polling (no webhook setup needed)
- Inline keyboard buttons for tool approval
- Typing indicator while processing
Discord
1. Create a Bot
- Go to Discord Developer Portal
- Create a New Application
- Go to Bot tab, click Add Bot
- Copy the bot token
- Under Privileged Gateway Intents, enable Message Content Intent
- Go to OAuth2 > URL Generator, select
botscope withSend MessagesandRead Message Historypermissions - Use the generated URL to invite the bot to your server
2. Install the Gateway
cargo install --git https://github.com/giosakti/duragent.git duragent-gateway-discord
3. Configure
# duragent.yaml
gateways:
external:
- name: discord
command: duragent-gateway-discord
env:
DISCORD_BOT_TOKEN: ${DISCORD_BOT_TOKEN}
restart: on_failure
routes:
- match:
gateway: discord
agent: my-assistant
Note: If you compiled Duragent with
--features gateway-discord, you can use the built-in config instead:gateways: discord: enabled: true bot_token: ${DISCORD_BOT_TOKEN}
4. Start
export DISCORD_BOT_TOKEN=your-token
export OPENROUTER_API_KEY=your-key
duragent serve
Discord Features
- DM and server channel support
- Button components for tool approval
- 2000-character message chunking
- Reply threading
- Typing indicator while processing
Multiple Gateways
You can run multiple gateways simultaneously with different routing:
gateways:
telegram:
enabled: true
bot_token: ${TELEGRAM_BOT_TOKEN}
external:
- name: discord
command: duragent-gateway-discord
env:
DISCORD_BOT_TOKEN: ${DISCORD_BOT_TOKEN}
routes:
- match:
gateway: telegram
chat_type: group
agent: group-assistant
- match:
gateway: discord
agent: discord-assistant
- match: {}
agent: default-assistant
Custom Gateways
You can write custom gateways in any language. They communicate with Duragent via JSON Lines over stdio. See Gateway Plugins for the protocol specification.
gateways:
external:
- name: my-custom-gateway
command: ./my-gateway-binary
restart: always