This repository contains an application that allows you to add OpenAI Assistants to your Discord server. The application uses Appwrite as the database for tracking the threads and assistants.
DISCLAIMER: This personal project is in early development and this README is still under construction. It is required that you have some knowledge on the technologies used or are interested in researching by yourself since you will have to do some things manually to make this work.
The project is structured as a monorepo using Nx, which helps with sharing code between the backend and frontend, and improves the development experience with integrated testing and building.
- Add OpenAI Assistants to your Discord server.
- Conversations are done in Discord threads. Only one OpenAI assistant can be added in the thread.
- Slash commands to manage the bots.
- Node.js
- Typescript
- Nx for monorepo management.
- Appwrite for database management.
- OpenAI for AI Assistants.
- Discord.js for the Discord bots.
- You need to separately setup Appwrite and put the credentials in the
.env
file. - You must have an OpenAI account and must provide your own API Key in the
.env
file. - One OpenAI Assistant is also one Discord bot. See OpenAI Assistants to create OpenAI Assistants, and Discord Developer Portal for creating Discord bots.
- You must create a Supervisor bot which you will use for managing the AI bots. See Discord Developer Portal for creating Discord bots.
- Clone the repository.
- Install dependencies with
npm install
. - Import the Appwrite schema
appwrite.json
to your Appwrite instance usingappwrite
command. See Appwrite CLI for more information. - Go to Appwrite server and in the
SystemConfg
collection, create a document with the following data:{ "config_name": "supervisor_discord_token", "config_value": "<insert discord token here>" }
- Go to your Appwrite server and add the details of your bots to the
Assistants
collection. - Configure
.env
. Refer to the.env.sample
file. - Run the app
npm serve sidekicks
.
After setting up the application, you can now go to your Discord server and start interacting with the OpenAI Assistants.
To start a conversation, just mention the OpenAI assistant in any channel the bots have access to.
Supervisor slash commands are available:
-
restart
for reloading the bots -
add-sidekick
for adding new bot -
...more to come soon!
There is an existing Dockerfile that you can use to containerize the app.
Run nx docker-build sidekicks
to build a docker image. Default tag is sidekicks
.
See apps/sidekicks/project.json
file and look for docker-*
targets for more information.
Sample docker-compose.yml
:
version: "3.8"
services:
sidekicks:
image: sidekicks
restart: unless-stopped
environment:
- OPENAI_API_KEY=
- APPWRITE_ENDPOINT=http://localhost:8080/v1
- APPWRITE_PROJECT=
- APPWRITE_API_KEY=
- TZ=Asia/Manila