> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent with User Memory

> Discord agent with agentic memory and web search using SqliteDb.

## Code

```python agent_with_user_memory.py theme={null}
from textwrap import dedent

import discord
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.integrations.discord import DiscordClient
from agno.models.google import Gemini
from agno.tools.websearch import WebSearchTools

db = SqliteDb(db_file="tmp/discord_client_cookbook.db")

personal_agent = Agent(
    name="Basic Agent",
    model=Gemini(id="gemini-3.7-flash"),
    tools=[WebSearchTools()],
    add_history_to_context=True,
    num_history_runs=3,
    add_datetime_to_context=True,
    markdown=True,
    db=db,
    enable_agentic_memory=True,
    instructions=dedent("""
        You are a personal AI friend of the user, your purpose is to chat with the user about things and make them feel good.
        First introduce yourself and ask for their name then, ask about themeselves, their hobbies, what they like to do and what they like to talk about.
        Use DuckDuckGo search tool to find latest information about things in the conversations
                        """),
    debug_mode=True,
)

discord_intents = discord.Intents.default()
discord_intents.message_content = True
discord_bot = discord.Client(intents=discord_intents)
discord_agent = DiscordClient(agent=personal_agent, client=discord_bot)
if __name__ == "__main__":
    discord_agent.serve()
```

## Usage

<Snippet file="create-venv-step.mdx" />

**1. Configure the Discord bot**

Enable the privileged Message Content Intent in the Discord Developer Portal. Invite the bot with View Channels, Send Messages, Read Message History, Create Public Threads, and Send Messages in Threads permissions.

**2. Set your API keys**

```bash theme={null}
export GOOGLE_API_KEY=xxx
export DISCORD_BOT_TOKEN=xxx
```

**3. Install dependencies**

```bash theme={null}
uv pip install -U agno google-genai ddgs sqlalchemy discord.py
```

**4. Run Agent**

Save the code above as `agent_with_user_memory.py`, then run:

```bash theme={null}
python agent_with_user_memory.py
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.