Skip to main content

Discord AI ChatBot : Context-Aware, Replies to Mentions AND also DMs

Workflow preview

Workflow preview
100%
Discord AI ChatBot : Context-Aware, Replies to Mentions AND also DMs preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Click here to access this Workflow for free . Get your own custom ChatGPT inside your Discord Server Descriptio...

Best for

  • Support Chatbot automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.memorybufferwindow, n8n-nodes-base.set, n8n-nodes-base.if, n8n-nodes-base.discord, n8n-nodes-base.webhook, n8n-nodes-discord-trigger.discordtrigger

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Theo Marcadet.

Original n8n.io source

1.1 Workflow description

Title
Discord AI ChatBot : Context-Aware, Replies to Mentions AND also DMs
Workflow name
Discord AI ChatBot : Context-Aware, Replies to Mentions AND also DMs

Click here to access this Workflow for free.


Get your own custom ChatGPT inside your Discord Server

Description

This n8n workflow enables a fully autonomous AI assistant within your Discord server. It listens for both public mentions and direct messages (DMs), and replies in real-time using a language model (OpenAI's GPT-4o by default). The assistant can dynamically fetch previous messages for better context, providing smart, coherent, and personalized responses.


πŸ”§ Key Features

  • Dual Trigger: Reacts to both public bot mentions and private DMs.
  • Context-Aware AI: Dynamically fetches the last 30 messages from either public or private conversations.
  • Smart Routing: Replies either in the original public channel or via DM, depending on where the message came from.
  • Custom Prompting: Easily modify the system prompt to define the AI’s tone, behavior, and personality.
  • Fully Autonomous: No manual intervention required β€” the bot always replies instantly.

βœ… Requirements

  • An operational n8n instance.
  • A Discord bot with at least these permissions:
    • Send Messages
    • Read Message History
    • Manage Messages
  • OpenAI API key (or compatible LLM credentials).
  • The community package: n8n-nodes-discord-trigger.

🧰 Setup Instructions

1. Discord Bot Setup
  • Create and invite your Discord bot to your server with required permissions. > You will find in the next step a complete tutorial to craft your own bot with the right code and permissions for this workflow to work
  • Set your Discord bot token in n8n's credential manager.
2. Install the Community Node (please read ⚠️ Disclaimer first)
  • Go to Settings > Community Nodes > Install
  • Paste: n8n-nodes-discord-trigger and install.
3. Configure the Workflow
  • Add your Discord bot credentials.
  • Update the LLM credentials with your OpenAI key or alternative.
  • Customize the AI agent system prompt if needed.

πŸ€– How It Works

  • When a public mention is detected, the bot replies directly in the channel, referencing the original message.
  • When a DM is received, it responds privately.
  • The AI uses tools to read the latest 30 public or private messages to build accurate context before replying.

πŸ›  Customization Options

  • Change LLM: Swap out OpenAI with any LLM that has an API.
  • Edit Prompt Behavior: Modify the system prompt to control tone and personality.
  • Adjust Trigger Filters: Choose which roles, channels, or patterns activate the flow.

If you just need a tutorial on setting up your Discord bot, be my guest ➑️ Here


And if you need any help, or have any question, feel free to come discuss about it on Telegram

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.8

Block 2 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 3 - Simple Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryBufferWindow - memoryBufferWindow
Config choices
Version 1.3

Block 4 - Mapping data for the Agent

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 5 - Either the bot should reply in dm or in public channel

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 6 - Reply in DM

Type / Role
n8n-nodes-base.discord - discord
Config choices
Version 2

Block 7 - Reply in public channel

Type / Role
n8n-nodes-base.discord - discord
Config choices
Version 2

Block 8 - DM Received

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

Block 9 - Public Mention

Type / Role
n8n-nodes-discord-trigger.discordTrigger - discordTrigger
Config choices
Version 1

Block 10 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Sticky Note9

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Read last public messages

Type / Role
n8n-nodes-base.discordTool - discordTool
Config choices
Version 2

Block 16 - Read last private messages

Type / Role
@n8n/n8n-nodes-langchain.toolHttpRequest - toolHttpRequest
Config choices
Version 1.1

Block 17 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Discord AI ChatBot : Context-Aware, Replies to Mentions AND also DMs
Complexity advanced
Nodes 18
Categories Support Chatbot, AI Chatbot
Author Theo Marcadet
Published 24 Apr 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3692/3692.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Discord AI ChatBot : Context-Aware, Replies to Mentions AND also DMs do?

Click here to access this Workflow for free . Get your own custom ChatGPT inside your Discord Server Descriptio...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Support Chatbot, AI Chatbot use case.