name: Discord Integration description: Send messages to Discord channels via webhook or bot metadata: { "openclaw": { "emoji": "๐ฎ", "requires": { "bins": ["curl"] }, "always": false }
}
Discord Integration
Send messages from your Gotchi to Discord. Two options:
Option 1: Webhook (Easy, Recommended)
No bot token needed! Just create a webhook in Discord.
Setup
- Discord Server โ Channel Settings โ Integrations โ Webhooks
- Create Webhook, copy URL
- Add to
.env:DISCORD_WEBHOOK=https://discord.com/api/webhooks/xxx/yyy
Send Message
curl -H "Content-Type: application/json" \
-d '{"content":"Hello from Gotchi!"}' \
"$DISCORD_WEBHOOK"
Send with Username & Avatar
curl -H "Content-Type: application/json" \
-d '{
"username": "Gotchi",
"avatar_url": "https://example.com/gotchi.png",
"content": "Status update!"
}' \
"$DISCORD_WEBHOOK"
Send Embed (Rich Message)
curl -H "Content-Type: application/json" \
-d '{
"username": "Gotchi",
"embeds": [{
"title": "๐ค System Status",
"color": 5814783,
"fields": [
{"name": "Temperature", "value": "42ยฐC", "inline": true},
{"name": "Memory", "value": "120MB free", "inline": true},
{"name": "Uptime", "value": "3 days", "inline": true}
],
"footer": {"text": "Raspberry Pi Zero 2W"}
}]
}' \
"$DISCORD_WEBHOOK"
Python Helper
import os
import requests
WEBHOOK = os.environ.get("DISCORD_WEBHOOK")
def send_discord(message: str, username: str = "Gotchi"):
if not WEBHOOK:
return False
requests.post(WEBHOOK, json={
"username": username,
"content": message
})
return True
# Usage
send_discord("Hello from Pi! ๐ค")
Option 2: Inbound Bot (Interactive)
OpenClawGotchi can run a Discord inbound adapter alongside Telegram.
Setup
- Create app at https://discord.com/developers/applications
- Create Bot, copy token
- Enable "Message Content Intent" in Bot settings
- Invite bot to server with permissions to read/send messages
- Add to
.env:DISCORD_BOT_TOKEN=your_bot_token DISCORD_ALLOWED_CHANNELS=123456789 DISCORD_ALLOWED_USERS= DISCORD_RESPOND_TO_ALL=0 DISCORD_MAX_ATTACHMENT_MB=15
Behavior
- DMs respond when
DISCORD_ALLOWED_USERSis set for that user, orALLOW_ALL_USERS=1. - Server channels must be listed in
DISCORD_ALLOWED_CHANNELS. - In server channels, the bot responds when mentioned by default.
- Set
DISCORD_RESPOND_TO_ALL=1to answer every message in allowed channels. - Image attachments use OpenAI Vision and are saved to the vault.
- Audio attachments use OpenAI Whisper and are passed through the normal LLM flow.
Option 3: Simple Send Script (Advanced)
Requires Discord bot token and discord.py library.
Setup
- Create app at https://discord.com/developers/applications
- Create Bot, copy token
- Enable "Message Content Intent" in Bot settings
- Invite bot to server with
applications.oauth2URL - Add to
.env:DISCORD_BOT_TOKEN=your_bot_token DISCORD_ALLOWED_CHANNELS=123456789 - Install:
pip install discord.py
Simple Send Script
#!/usr/bin/env python3
import os
import discord
import asyncio
TOKEN = os.environ.get("DISCORD_BOT_TOKEN")
CHANNEL_ID = int(
os.environ.get("DISCORD_ALLOWED_CHANNELS", os.environ.get("DISCORD_CHANNEL_ID", "0")).split(",")[0]
)
async def send_message(content: str):
intents = discord.Intents.default()
client = discord.Client(intents=intents)
@client.event
async def on_ready():
channel = client.get_channel(CHANNEL_ID)
if channel:
await channel.send(content)
await client.close()
await client.start(TOKEN)
if __name__ == "__main__":
import sys
msg = sys.argv[1] if len(sys.argv) > 1 else "Hello from Gotchi!"
asyncio.run(send_message(msg))
Usage
python3 discord_send.py "System alert: Temperature high!"
Integration Ideas
Heartbeat โ Discord
Add to your heartbeat to post status updates:
# In src/bot/heartbeat.py, after reflection
webhook = os.environ.get("DISCORD_WEBHOOK")
if webhook:
import requests
requests.post(webhook, json={
"username": "Gotchi",
"content": f"๐ Heartbeat: {stats['temp']}ยฐC, {stats['mem_avail']}MB free"
})
Alert on Problems
if stats["temp"] > 70:
send_discord("โ ๏ธ Temperature critical: {}ยฐC!".format(stats["temp"]))
Daily Summary
Schedule via cron:
/cron 24h Post daily summary to Discord
Webhook vs Bot
| Feature | Webhook | Bot |
|---|---|---|
| Send messages | โ | โ |
| Read messages | โ | โ |
| React to messages | โ | โ |
| Respond to commands | โ | โ |
| Setup complexity | Easy | Medium |
| Dependencies | curl | discord.py |
| RAM usage | ~0 | ~30MB |
Recommendation: Start with webhook. Add bot later if you need interaction.