• /chat [message] Chat with ChatGPT!
  • /private ChatGPT switch to private mode
  • /public ChatGPT switch to public mode
  • /reset ChatGPT conversation history will be erased




  • public mode (default) the bot directly reply on the channel
  • private mode the bot’s reply can only be seen by the person who used the command



  1. pip install -r requirements.txt
  2. Rename the file config.dev.json to config.json

Step 1: Create a Discord bot

  • Go to https://discord.com/developers/applications and create an application
  • Build a Discord bot under the application
  • Get the token from the bot setting
  • Store the token to config.json under the discord_bot_token
  • Invite your bot to your server via OAuth2 URL Generator

Step 2: Geanerate a OpenAI API key

  • Go to https://beta.openai.com/account/api-keys
  • Click Create new secret key
  • Store the SECRET KEY to config.json under the openAI_key

Step 3: Run the bot on the desktop

  1. Open a terminal or command prompt
  2. Navigate to the directory where you installed the ChatGPT Discord bot
  3. Run python3 main.py to start the bot

Step 3: Run the bot with Docker

  1. Build the Docker image & Run the Docker container docker compose up -d
  2. Inspect whether the bot works well docker logs -t chatgpt-discord-botStop the bot:
    • docker ps to see the list of running services
    • docker stop <BOT CONTAINER ID> to stop the running bot

Have a good chat!

Optional: Setup starting prompt

  • A starting prompt would be invoked when the bot is first started or reset
  • You can set it up by modifying the content in starting-prompt.txt
  • All the text in the file will be fired as a prompt to the bot
  • Get the first message from ChatGPT in your discord channel!
  • Right-click the channel you want to receive the message, Copy ID
  • paste it into config.json under discord_channel_id

Download Source Code