Part 4: Create Our Own Discord Bot

Build a custom Discord bot and connect it to our n8n AI automation.

15. (Optional) Create Our Own Discord Bot

In this optional advanced section, we will create our own Discord bot.

The bot will allow our n8n workflow to send messages to a Discord server automatically.

Our goal:

You submit request → AI processes it → Our Discord bot sends the result to the Discord channel.

15.1 Open Discord Developer Portal

Open the Discord Developer Portal.

  1. Create a new application.
  2. Give your application a name.
  3. Open the application.

Open Discord Developer Portal →

15.2 Create the Bot

  1. Open the Bot section of your Discord application.
  2. Create the bot.
  3. Give the bot a suitable name.
  4. Set a profile picture if required.

Example Bot Name

AI Horizon Assistant

15.3 Install the Bot

Configure the bot's installation settings and invite it to your Discord server.

Required Permissions

Give only the permissions that the bot actually needs.

15.4 Protect the Bot Token

Important Security Warning

Your Discord bot token is private.

Never share it publicly.

  • Do not upload it to GitHub.
  • Do not post it in Discord.
  • Do not put it in screenshots.
  • Do not put it directly into public source code.

Store the bot credentials securely using the n8n credential system.

15.5 Connect the Bot to n8n

After the bot has been created and invited to the Discord server, configure the Discord node in n8n.

  1. Open the Discord node.
  2. Create or select the required Discord credential.
  3. Configure the server.
  4. Select the Discord channel.
  5. Configure the message.

15.6 Final Workflow

Student Form → AI / Groq → Custom Discord Bot → Discord Channel

15.7 Example Bot Message

AI Horizon Assistant

New Student Request

Student: Hari Bahadur

Department: SSD

Subject: Leave Request

Message:

I am feeling unwell today and will not be able to attend my classes. I would therefore like to request leave for today.

15.8 Optional Challenge

Try modifying the bot message so that it automatically includes:

Challenge:

Can you make the Discord bot produce a clean notification automatically every time a student submits the form?

Ready for Part 5?

In the final part, we will run n8n locally using Docker and expose it using a Cloudflare Quick Tunnel.

Continue to Part 5: Local Deployment →