Daia (Discord AI Agent) is an intelligent Discord bot powered by Google Gemini and built on the PocketFlow framework. It provides conversational AI capabilities with advanced features like markdown table rendering, message history processing, and Google Search integration.
- AI-Powered Conversations: Leverages Google Gemini for natural language understanding and generation.
- User Recognition: Recognizes and addresses users by their display name for a personalized experience.
- Smart Message Processing: Processes Discord message history with context awareness.
- Markdown Table Rendering: Automatically converts markdown tables to images using Noto Sans CJK fonts. Supported languages include but are not limited to English, Simplified Chinese (简体中文), Traditional Chinese (繁體中文), Japanese (日本語), and Korean (한국어).
- Smart Chunking: Automatically splits long messages into smaller chunks, preserving markdown formatting to avoid Discord's character limit.
- Google Search Integration: Built-in search capabilities through Gemini tools.
- Slash Commands: Includes a
/newchat
command for starting fresh conversation sessions.
- A Discord Bot Token. You can follow the official guide to create one: Discord Developer Documentation.
- A Google Gemini API Key. You can obtain one from Google AI Studio.
This project requires Python 3.12+. uv
will gracefully handle the Python version requirement, create a virtual environment, and manage all project dependencies for you.
-
Clone the repository:
git clone https://github.com/zhiro-labs/daia.git cd daia
-
Install dependencies:
uv sync
ℹ️ Note: If you don't have
uv
installed, you can follow the official installation guide: https://docs.astral.sh/uv/getting-started/installation/ -
Configure your environment and system prompt:
- Copy the example files to create your own configuration:
cp .env.example .env cp config/chat_sys_prompt.txt.example config/chat_sys_prompt.txt
- Edit the
.env
file to add your Discord bot token and Gemini API key. - Edit
config/chat_sys_prompt.txt
to customize the bot's personality and instructions.
- Copy the example files to create your own configuration:
-
Run the bot:
uv run main.py
For the bot to function correctly, you need to configure its permissions and intents in the Discord Developer Portal.
Navigate to your bot's settings in the Discord Developer Portal and enable the following privileged gateway intents:
- Server Members Intent: Required for the bot to recognize and address users by their display name.
- Message Content Intent: Required for the bot to read message content.
When inviting the bot to your server, ensure it has the following permissions:
- General Permissions
- View Channels
- Text Permissions
- Send Messages
- Attach Files
- Read Message History
Daia is configured using environment variables. These can be set in a .env
file in the project root.
DISCORD_BOT_TOKEN
: Your Discord bot token. (Required)GEMINI_API_KEY
: Your Google Gemini API key. (Required)ALLOWED_CHANNELS
: A comma-separated list of channel IDs where the bot is allowed to respond without being mentioned. If this is not set, the bot will only respond to direct messages and mentions.HISTORY_LIMIT
: The maximum number of messages to fetch from the channel history. (Required)CHAT_MODEL
: The Gemini model to use (e.g., "gemini-1.5-flash", "gemini-1.5-pro"). (Required)CHAT_TEMPERATURE
: Controls the randomness of Gemini's responses (range: 0.0–2.0). (Required)CHAT_SYS_PROMPT_PATH
: The path to the system prompt file. (Required)ENABLE_CONTEXTUAL_SYSTEM_PROMPT
: Set toon
to enable the contextual system prompt, which allows the bot to recognize and address users by their display name. The recommended setting ison
(as set in.env.example
). If the variable is not set, it defaults tooff
.LLM_PROVIDER
: The LLM provider to use. Currently supportsgemini
. Defaults togemini
.
Daia is designed for easy interaction. Here's how you can use its features:
-
Start a Conversation: To begin interacting with Daia, you have several options:
- In allowed channels: If
ALLOWED_CHANNELS
is configured with specific channel IDs, you can directly send messages in those channels without mentioning the bot. - Mention the bot: In any channel where the bot has access, mention it (e.g.,
@Daia hello!
) to start a conversation. - Direct Message: Send the bot a Direct Message (DM) to chat privately.
- In allowed channels: If
-
Continue the Conversation: Daia remembers the recent conversation history. You can simply send a new message to continue the conversation without needing to mention the bot again.
-
Start a New Chat Session: To start a fresh conversation and clear the context, use the
/newchat
slash command. This will make the bot forget the previous conversation history in that channel. -
Automatic Table Rendering: When Daia's response contains a markdown table, it will automatically be rendered as an image for better readability. This feature works automatically without any specific commands.
-
Google Search: If you ask a question that requires up-to-date information, Daia will automatically use its Google Search tool to find the answer.
-
Long Message Handling: Daia automatically splits long messages into multiple smaller ones, preserving the original formatting. This is an automatic feature to work around Discord's character limit.
.
├── .env.example
├── .gitignore
├── main.py
├── pyproject.toml
├── README.md
├── nodes/
│ ├── __init__.py
│ ├── contextual_system_prompt.py
│ ├── fetch_history.py
│ ├── llm_chat.py
│ ├── process_history.py
│ ├── send_response.py
│ ├── table_extractor.py
│ └── table_renderer.py
├── utils/
│ ├── __init__.py
│ ├── config_utils.py
│ ├── discord_helpers.py
│ └── download_font.py
└── ...
Contributions are welcome! Please feel free to submit a pull request or open an issue.
- Reply message rearrange
- Timezone setting
- daia-ignore tag
- Image processing
- YouTube processing
- Deep search
- Smart reply channels
- Gemini safety setting
- MCP support
- OpenAI support
- OpenAI compatible support
- Database support
- Long-term memory
- Dive deeper cookbook/pocketflow-thinking on PocketFlow
- Inspired by PocketFlow by Zachary Huang
- The cover background photo was shot by Çağrı KANMAZ on Pexels