A Discord bot that analyzes direct messages between you and your partner, allowing you to search and query conversation history, track shared links, and more. Perfect for finding those furniture links you shared months ago!
- Message History Storage: Securely stores your DM history in a SQLite database
- Link Detection & Categorization: Automatically detects and categorizes links shared in conversations
- AI-Powered Querying: Ask natural language questions about your conversation history
- Furniture Focus: Special features for tracking furniture links and discussions
- Val.town Integration: Runs on Val.town for easy deployment and scheduling
- Periodic Updates: Automatically fetches new messages on a schedule
- "Show me all the sofas we discussed last month"
- "What did we say about the IKEA table?"
- "Find all the furniture links we shared since January"
- "Summarize our discussion about the dining room"
- Node.js 16+ and npm
- Discord account with Bot token
- OpenAI API key (for AI-powered queries)
- Val.town account (for deployment)
-
Clone this repository
git clone <repository-url> cd discord-bot
-
Install dependencies
npm install
-
Create a
.env
file based on.env.example
cp .env.example .env
-
Fill in the required environment variables in
.env
:DISCORD_TOKEN
: Your Discord bot tokenDISCORD_CLIENT_ID
: Your Discord application client IDDISCORD_USER_ID
: Your Discord user IDSPOUSE_USER_ID
: Your partner's Discord user IDOPENAI_API_KEY
: Your OpenAI API key
-
Initialize the database
node index.js
-
Test the DM fetching process
node val-town-cron.js
-
Install the Val.town CLI
npm install -g val-town-cli
-
Authenticate with Val.town
vt login
-
Deploy the application to Val.town
node val-town-deploy.js
-
Configure Val.town environment variables
- Go to the Val.town dashboard
- Add the same environment variables from your
.env
file
-
Set up a scheduled task on Val.town for periodic DM fetching
- Create a new scheduled task using the Val.town dashboard
- Use the
discordDMBotCron
function - Set the schedule (e.g., every 6 hours)
- Go to the Discord Developer Portal
- Create a New Application
- Go to the "Bot" tab and create a bot
- Under "Privileged Gateway Intents", enable:
- Message Content Intent
- Server Members Intent
- Copy the bot token to your
.env
file - Invite the bot to your server using the OAuth2 URL Generator
- Select "bot" scope
- Select permissions: Read Messages/View Channels, Read Message History
- Start a DM with your partner to create the DM channel the bot will monitor
The application exposes the following HTTP endpoints:
GET /health
: Health check endpointPOST /api/fetch-dms
: Manually trigger DM fetchingPOST /api/process-links
: Manually trigger link processingPOST /api/query
: Submit a query about your message history- Body:
{ "query": "your question here", "filters": { optional filters } }
- Body:
POST /api/commands/search
: Discord command endpoint for searching- Body:
{ "query": "your search term" }
- Body:
Once set up, you can interact with the bot using the following commands:
/search [query]
: Search your conversation history/links [category]
: Show links from a specific category/categories
: List all available link categories/analyze [query]
: Analyze your conversation with AI
The application uses a SQLite database with the following tables:
messages
: Stores all DM messagesattachments
: Stores message attachmentsembeds
: Stores message embedslinks
: Stores extracted links with categoriescategories
: Stores link categoriesconversations
: Stores AI-generated conversation summaries
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Discord.js for Discord API integration
- OpenAI for AI-powered querying
- Val.town for hosting and scheduling
- Better-SQLite3 for database management