A Discord bot for natural language surveys, inspired by and in the style of talk to the city.
Join the Discord server for discussing and developing this tool here.
Create a .env.local
file with the following variables:
DISCORD_TOKEN=XXXXXXXXX
OPENAI_API_KEY=XXXXXXXXX
# Redis host without port
REDIS_HOST=XXXXXX
REDIS_PORT=XXXXX
REDIS_PASSWORD=XXXXXXX
CLIENT_ID=XXXXXXXXX
GUILD_ID=XXXXXXXXXX
# Log Level, DEBUG, INFO, WARN etc.
GSS_LOG_LEVEL=XXXXX
SUMMARIZE_FREQUENCY_SECONDS=3600
# Discord forum channel id for posting channels.
POST_CHANNEL_ID=XXXXX
Run npm install
Fill in the REDIS_HOST, REDIS_PORT, and REDIS_PASSWORD for connecting your Redis DB:
connect
. Copy and paste your password, socket, and port into the .env.local
file.config.js
.Start the main bot script with npm run bot
.
Or start the main bot script with npm run dev
to use nodemon in the development phase.
Start the GPT summarization script with npm run summarizer
.
Here is the section for the scripts in the README file:
The project includes several scripts to facilitate development and operations. Here is a brief explanation of each:
Runs the tests.
npm run test
Starts the main bot script.
npm run bot
Starts the main bot script in development mode using Nodemon to automatically restart the bot when changes are detected.
npm run dev
Starts the GPT summarization script.
npm run summarizer
Formats the codebase using Prettier.
npm run prettier
Resets the Redis database.
npm run reset
Use it to create single question surveys.
YYYY-MM-DD-HH-MM
format or can be inf
true
or false
Use it to create multiple question surveys.
enter
is one question. Each question must be maximum 45 Char for each line. Maximum question number is maxResponsesForMultiResponsePerUser
in constants.ts. However it is strongly recommended to set is maximum 5 to prevent Modal UI based problems.YYYY-MM-DD-HH-MM
format or can be inf
true
or false
You can use this if you want to post an active survey in another channel (bot must have access to post anything on that channel).
To view the responses with raw data txt file.
You can use this command to show people summaries of surveys. You can select summary type optionally: If "Yes", it will show high level summary of the survey. If "No", it will show general summary.
Edit survey name or questions, delete questions or add questions. Once submitted, if the survey was answered, the responses will be deleted. You can also set/edit a survey start and end date, or leave it infinite. Also, you can post the survey to forum channel making `true
the last section.
Same restrictions in /create
command.
And if your survey in the forum channel. Do not change the title more than 2 times in 10 Minutes because of rate limit.
To activate or deactivate a survey.
To delete the survey.
To check the version.
To start auto-posting the responses view. It is working which channel that you used. For example, if you use it in forum channel, it will be activated in that channel.
To stop auto-posting the responses view. For example, if you use it in forum channel, it will be activated in that channel.
docker build -t <your-image-name>:<your-image-tag> .
The image has two operational modes: bot by default and summarizer.
To run the bot, use the bot
argument, and to run the summarizer, use summarizer
.
docker run -it -d --env-file ./.env <your-image-name>:<your-image-tag> bot
The --env-file
flag takes a filename as an argument and expects each line to be in the VAR=VAL format, mimicking the argument passed to --env
. Comment lines need only be prefixed with #
.
docker-compose up --build
TODO
connect
. Copy and paste your password, socket, and port into the .env.local
file.To get the Guild ID, you must ensure that "Developer Mode" is enabled in your Discord client settings.
npm run bot
to start your bot.redis://localhost:6379
. For remote instances, configure according to your provider's instructions.commands
folder for command related codes. can be used by importing @command/index
lib
folder for other functional codes.βββ πgptSurveySummarizer
βββ .env.local
βββ .gitignore
βββ CODEOWNERS
βββ Dockerfile
βββ README.md
βββ SETUP.md
βββ docker-compose.yaml
βββ dump.rdb
βββ initial_notes.md
βββ package-lock.json
βββ package.json
βββ settings.json
βββ πsrc
βββ bot.ts
βββ πcommands
βββ commandBuilder.ts
βββ handleAutoPost.ts
βββ handleCreate.ts
βββ handleDelete.ts
βββ handleDeleteButton.ts
βββ handleEdit.ts
βββ handleInfo.ts
βββ handleModals.ts
βββ handleRespond.ts
βββ handleRespondButton.ts
βββ handleSetStatus.ts
βββ handleSummary.ts
βββ handleView.ts
βββ index.ts
βββ config.js
βββ constants.ts
βββ πlib
βββ checkUpdateSurveys.js
βββ createSurvey.js
βββ deleteThreadPost.js
βββ gptClient.js
βββ index.ts
βββ makeSurveyPost.js
βββ startAutoPosting.js
βββ surveyToText.js
βββ threadPost.js
βββ updateSurvey.js
βββ updateThreadPost.js
βββ logger.js
βββ prompts.js
βββ redisReset.ts
βββ summarizer.js
βββ πtest
βββ bot.test.js
βββ summarizer.test.js
βββ tsconfig.json
To make a contribution, follow these steps: