Discord AI chatbot with GPT-4o-mini & Redis memory persistence
Description: This n8n workflow automates a Discord bot to fetch messages from a specified channel and send AI-generated responses in threads. It ensures smooth message processing and interaction, making it ideal for m...
Template notes
Description: This n8n workflow automates a Discord bot to fetch messages from a specified channel and send AI-generated responses in threads. It ensures smooth message processing and interaction, making it ideal for managing community discussions, customer support, or AI-based engagement. This workflow leverages Redis for memory persistence, ensuring that conversation history is maintained even if the workflow restarts, providing a seamless user experience.
How It Works
- The bot listens for new messages in a specified Discord channel. - It sends the messages to an AI model for response generation. - The AI-generated reply is posted as a thread under the original message. - The bot runs on an Ubuntu server and is managed using PM2 for uptime stability. - The Discord bot (Python script) acts as the bridge, capturing messages from Discord and sending them to the n8n webhook. The n8n workflow then processes these messages, interacts with the AI model, and sends the AI's response back to Discord via the bot.
Prerequisites to host Bot - Sign up on [Pella](https://www.pella.app/), which is a managed hosting service for Discord Bots. (Easy Setup) - A Redis instance for memory persistence. Redis is an in-memory data structure store, used here to store and retrieve conversation history, ensuring that the AI can maintain context across multiple interactions. This is crucial for coherent and continuous conversations.
Set Up Steps
1️⃣ Create a Discord Bot
1. Go to the [Discord Developer Portal](https://discord.com/developers/applications). 2. Click “New Application”, enter a name, and create it. 3. Navigate to Bot > Reset Token, then copy the Bot Token. 4. Enable Privileged Gateway Intents (Presence, Server Members, Message Content). 5. Under OAuth2 > URL Generator, select bot scope and required permissions. 6. Copy the generated URL, open it in a browser, select your server, and click Authorize.
2️⃣ Deploy the Bot on Pella