Discord, a renowned digital platform, has seen massive use in recent years as it combines text, voice, and video communication, bringing people together over common interests. One of its pivotal features is the ability to integrate AI chatbots like ChatGPT, which can remarkably enhance user experience. Among these, MAIA (Messaging Artificial Intelligent Assistant) is a bot that embeds the power of ChatGPT, ensuring friendliness and utility at its best. The bot not only enlivens your Discord server but also keeps it informed and entertained, ultimately serving as a powerful tool to boost user engagement in your channel. In essence, MAIA serves as a valuable tool for those seeking to leverage AI technology within their Discord communities.
It's time to construct our Discord bot. To start, visit the Discord Developers Applications page. If you're not logged in yet, make sure to sign in. You'll see an option labelled "Create Application" on the right side of the page, click on it, then assign a name to your application. You are free to use any name you like. For example, I'll name mine "MAIA".
Begin by assigning an avatar to your application. Afterwards, proceed to the "bot" section located on the left-hand side of your screen and click "Create Bot". Once your bot has been created, adjust the following settings according to your preferences:
-
Deactivate the "Public Bot" setting if you wish to prevent others from inviting your bot.
-
Activate all the "Intense Settings":
-
Select OAuth2, which is on your screen's left, and choose "↳ URL Generator" to create an invitation link for your Discord bot. Within the scope section, select:
Application.commands (If you plan to include
/
commands)Proceed by navigating to the bot permissions section below and select:
To add the bot to your server, follow the standard procedure as with other bots. After enabling this setting, scroll down to find the generated URL. Copy this URL, then go to your Discord server. Paste the link into the chat and send it. Click the sent link to invite the bot to your server.
- Lastly, to obtain the bot token, click on "Bot" on the left side of your screen and select "Reset Token". This will produce a long string beneath the bot's username. Ensure you copy it. Once you navigate away, this key won't be accessible again. If lost, you'll have to reset the token.
- After copying the token, open your Discord app and navigate to your server. Paste the token and click on the link—follow the prompted steps to allow your bot into your server. Once you've invited the bot, it will appear on the Member list on your right-hand side; it will be offline initially.
With the bot now created and added to your Discord server, the next steps are straightforward, but they do involve some specific links and prerequisites for seamless operation. It's time to gather all the necessary keys. We've already created the Discord token; now it's time to create your OpenAI API Key if you don't already have one. This key is important for integrating ChatGPT with Discord.
To use MAIA's services in Discord, obtaining an OpenAI API key is critical. This key can be generated from your existing OpenAI account; if you don't have an OpenAI account, easily create one by visiting this link. This secret key is essential for authentication verification. Below is a detailed guide on acquiring the key:
- Log in to your OpenAI account.
- Search for the "Create new secret key" option and click on it.
After acquiring the API Key, integrating ChatGPT's services into Discord is fairly simple. Remember, once you copy the key and close the pop-up, you cannot access it again. Therefore, store the key in a secure location.
Now you've created the application and gathered all the necessary keys to operate the bot. You need to download the repository. Here are the two methods you can choose from:
Automatic Download via curl
: Simply execute the following command in your terminal to quickly download and seamlessly install the utility:
zsh -c "$(curl -fsSL https://raw.githubusercontent.com/nicolodiamante/MAIA/HEAD/bootstrap.zsh)"
Manual Cloning: For those who prefer a hands-on approach, you can manually clone the repository to your desired location:
git clone https://github.com/nicolodiamante/MAIA.git ~/MAIA
Directory Navigation & Script Execution: Navigate to the root directory of the repository, and then execute the installation script using the following command:
source utils/install.sh
MAIA Configuration:
Before initiating the script, confirm that your system has Node.js installed. If the script doesn't detect Node.js, it will attempt to install it via Homebrew. In the absence of Homebrew, the script will install Homebrew first and then proceed with the Node.js installation, followed by tmux.
Once Node.js is up and running, the script will automatically handle the installation of the necessary dependencies which include discord.js, dotenv, openai, and nodemon using npm, the Node.js package manager.
During this setup, a .env
file is created. This file is crucial as it is where you will enter your configuration settings.
# Discord Settings
DISCORD_TOKEN=
DISCORD_CHANNEL_ID=
Start by entering the Discord token you acquired earlier. If you want MAIA to operate in a specific channel, provide the DISCORD_CHANNEL_ID
. Leaving it blank means MAIA can respond in any channel on the server.
# OpenAI Configuration
OPENAI_ORG=
OPENAI_API_KEY=
Input the required values for OpenAI settings. This allows MAIA to communicate with OpenAI and generate responses.
# Chat Log Configuration
CHAT_LOG=0
The CHAT_LOG
configuration determines whether MAIA will log the chats. Enabling this can be useful for debugging or monitoring purposes. By default, it's set to '0', which means logging is disabled.
1. Enable Discord Developer Mode
Before you can obtain a Discord channel's ID, the Developer Mode needs to be activated. If you're a Discord bot developer, you might have already turned this on. If not, here's how to do it:
-
Launch Discord and find the settings icon, represented by a cogwheel, at the bottom left of the screen. It's near your avatar and username.
-
Click on the icon to open the User Settings.
-
In the left sidebar, select "Advanced" to access the Advanced Settings.
-
In the Advanced Settings, look for the Discord Developer Mode toggle. A green checkmark means it's already enabled. If not, click to turn it on.
2. Find and Copy the Channel ID
-
With Developer Mode on, you're set to obtain the channel's ID.
-
Locate and select the channel whose ID you want to retrieve.
-
On a desktop, right-click the channel name. A menu will pop up with a "Copy ID" option. Selecting this will copy the channel's ID to your clipboard. Refer to the screenshot below for clarity.
-
On mobile, press and hold the channel name until a menu surfaces. From this menu, choose "Copy ID" to copy the channel ID.
With the ID copied, you can use it as needed, like let MAIA know exactly which channel to operate in.
- Identify the Organization ID
- Go to OpenAI Organization settings.
- Locate and copy your OpenAI Organization ID.
- Update .env File
- In your
.env
file, locate theOPENAI_ORG
field. - Paste the copied Organization ID.
- Ensure you've also added the
OPENAI_API_KEY
you previously obtained.
By following these steps, your .env
file will be correctly configured with OpenAI's details.
Once you've set up the bot and keyed in your access details, follow these steps to deploy it, open the terminal, navigate to the MAIA directory, and initiate the bot. You can do this by executing the following command:
maia -s
If you have set everything up correctly, you'll see the message: "MAIA session started and detached!" This indicates that a new session named "maia_session" has started on tmux, and your bot is now online, ready to function on your Discord server. To view the active tmux sessions, execute the command below:
maia -a
MAIA is designed to function as a smart assistant within the background of your computing environment. Tmux enhances MAIA's operability by allowing it to run independently in the background. This means you can start MAIA, detach from the tmux session, and continue using your terminal for other tasks while MAIA remains active.
There may be instances where you need to pause MAIA's activity—perhaps for maintenance, updates, or simply to temporarily free up system resources. To manage this, MAIA includes simple-to-use commands that enable you to suspend its session and then, when you're ready, resume operation without having to restart the entire program.
In short, tmux is what gives MAIA the ability to work discreetly and persistently, ensuring your Discord interactions are managed efficiently without monopolising your terminal's workspace.
To start or re-attach to the session:
maia -s
To terminate the session:
maia -k
These commands offer you complete autonomy over MAIA's functionality on your system.
Post initiation or termination of the MAIA session, it's recommended to verify its status, ensuring its desired operational state:
maia -r
Upon successful execution, a corresponding message will display, showcasing the MAIA session's active or inactive status.
Through the integration of AI chatbots like MAIA, the user experience on Discord can be significantly improved. MAIA, powered by ChatGPT's innovative capabilities, injects vibrancy into your Discord server by delivering valuable and entertaining content to users. These highly sophisticated and appealing AI bots have the potential to boost user interaction and engagement within your Discord communities. By harnessing the power of AI technology through bots like MAIA, you can cultivate a lively, knowledgeable, and captivating atmosphere for all server members.
Thank you for considering the use of this chatbot. Your feedback on improving MAIA would be much appreciated. In case you run into any issues or bugs, please report them on the issues page.