Discord Bridge Skill
Overview
Bridges Discord messages to Agent Zero's api_message HTTP endpoint, enabling Discord users to interact with Agent Zero agents.
Purpose
- - Forward Discord messages from specific channels to Agent Zero
- Handle async Discord bot events
- Support command prefix filtering
- Session-based message bridging
Input Variables
| Variable | Description | Example |
|---|
| INLINECODE0 | Discord bot authentication token | Bot token from Discord Developer Portal |
| INLINECODE1 |
Agent Zero API endpoint | http://localhost:80/api_message |
|
{{A0_API_KEY}} | Agent Zero API authentication | mcp
servertoken from settings |
|
{{DISCORD_CHANNEL_IDS}} | Comma-separated allowed channel IDs | "123456789,987654321" |
|
{{BOT_CMD_PREFIX}} | Command prefix for bot commands | "!" |
Triggers
- - Discord
on_message event - Filtered by ALLOWEDCHANNELSET (if configured)
- Messages containing command prefix for special handling
APIs & Dependencies
- - discord.py: Discord bot framework
- aiohttp: Async HTTP client for API calls
- python-dotenv: Environment variable management
Files
- -
index.py - Main Discord bot logic - INLINECODE7 - Environment template
Usage
CODEBLOCK0
Discord 桥接技能
概述
将 Discord 消息桥接到 Agent Zero 的 api_message HTTP 端点,使 Discord 用户能够与 Agent Zero 代理进行交互。
目的
- - 将特定频道的 Discord 消息转发至 Agent Zero
- 处理异步 Discord 机器人事件
- 支持命令前缀过滤
- 基于会话的消息桥接
输入变量
| 变量 | 描述 | 示例 |
|---|
| {{DISCORDBOTTOKEN}} | Discord 机器人身份验证令牌 | 来自 Discord 开发者门户的机器人令牌 |
| {{A0APIURL}} |
Agent Zero API 端点 | http://localhost:80/api_message |
| {{A0
APIKEY}} | Agent Zero API 身份验证 | 设置中的 mcp
servertoken |
| {{DISCORD
CHANNELIDS}} | 允许的频道 ID(逗号分隔) | 123456789,987654321 |
| {{BOT
CMDPREFIX}} | 机器人命令前缀 | ! |
触发器
- - Discord onmessage 事件
- 通过 ALLOWEDCHANNEL_SET 过滤(如已配置)
- 包含命令前缀的消息进行特殊处理
API 与依赖项
- - discord.py:Discord 机器人框架
- aiohttp:用于 API 调用的异步 HTTP 客户端
- python-dotenv:环境变量管理
文件
- - index.py - Discord 机器人主逻辑
- .env.example - 环境模板
使用方法
bash
安装依赖
pip install discord.py aiohttp python-dotenv
配置环境
cp .env.example .env
使用你的凭据编辑 .env 文件
运行桥接程序
python index.py