A simple GPT discord bot with implementations in node.js and python.
-
You should have a discord server set up with a bot created. You can learn how to do this in the first half of this tutorial.
-
An embeddings vector DB that has been created with Supabase. You'll need to use the PGVector extension and create a function which allows you to run a k-nearest-neighbors search on the embeddings DB. There's a great tutorial on getting this set up by the Supabase team. You can find it here.
-
You'll need an OpenAI API Key. You can get this from OpenAI directly.
-
Create a new .env file based on
.env.templateand add your Supabase URL & key, Discord token, and OpenAI API key there. -
Finally, you should have up to date versions of node and python on your machine.
Once you have your embeddings DB and discord bot set up in the Discord developer portal, you'll want to choose either the python or node implementation.
- Run
npm installto install deps - Be sure to change the
companyNameandbotNamevariables to reflect your company's name and the name of your bot. ThebotNameMUST match the name of the discord bot you created in the Discord developer dashboard. - Start the server by running node node/index.js
- Tag your bot in a new discord message with @myBotName and ask it a question. If everything works correctly, your bot should create a new thread with the chatGPT response there.
- Use
pip installto install deps:
pip install -U discord.pypip install langchainpip install openaipip install supabase
- Be sure to change the
company_nameanddiscord_bot_namevariables to reflect your company's name and the name of your bot. Thediscord_bot_nameMUST match the name of the discord bot you created in the Discord developer dashboard. - Start the server by running python python/index.js
- Tag your bot in a new discord message with @myBotName and ask it a question. If everything works correctly, your bot should create a new thread with the chatGPT response there.