Integration Guides
Creating an AI Discord Bot
Mendable provides an easy way to create a Discord bot that can answer questions about your project. This guide will show you how to create a Discord bot that uses the Mendable API to answer questions and provide sources for the answers. It creates a new thread for each question asked and stores the history of the conversation.
Features
- Starts a new thread for each question asked.
- Uses the Mendable API to answer questions and provide sources.
- Stores the history of the conversation.
Setup
- Clone Mendable AI Discord Bot repository.
- Install the required dependencies with
npm install. - Create a
.envfile in the root directory of the project and add the following environment variables: - Run the bot with
node index.jsornpm run start.
Usage
To ask a question, mention the bot followed by your question. For example:
@MendableAI How to create a Mendable AI Discord Bot?
The bot will create a new thread, answer the question, and provide sources for the answer.
Dependencies
discord.js: A powerful library for interacting with the Discord API.dotenv: A zero-dependency module that loads environment variables from a.envfile intoprocess.env.
Creating a Discord Application and Getting the Necessary Tokens
Create a Discord Application
- Go to the Discord Developer Portal.
- Click on the
New Applicationbutton. - Give your application a name and click
Create.
Create a Bot for the Application
- Click on the
Bottab on the left side of the application page. - Click on the
Add Botbutton on the right and confirm by clickingYes, do it!.
- Click on the
Get the Bot Token
- Still on the
Bottab, find theTokensection. - Click on
Copyto copy the bot token. This is yourDISCORD_TOKEN.
- Still on the
Get the Bot ID
- Go to the
General Informationtab on the left side of the application page. - Find the
Application IDsection and clickCopy. This is yourBOT_ID.
- Go to the
Invite the Bot to Your Server
- Go to the
OAuth2tab on the left side of the application page. - In the
Scopessection, selectbot. - In the
Bot Permissionssection, select the permissions your bot needs. - Copy the generated URL and open it in your web browser to invite the bot to your server.
- Go to the
Get the Bot ID
- Right click on the bot name and select
Copy ID. This is yourBOT_ID.
- Right click on the bot name and select