This is a Twitch chatbot that uses TMI.js for Twitch chat interaction and GPT OpenAI for generating responses based on user prompts.
Clone the repository:
git clone https://github.com/haldahini/GPTBotTwitch.git
cd GPTBotTwitch
Install dependencies using npm or yarn:
npm install
# or
yarn install
Create a .env
file based on the .env.example
:
USERNAME
: Make sure to replace 'USERNAME' with your actual bot's Twitch username.DEBUG
: Set totrue
for tmi.js debugOAUTH_TOKEN
: Your Twitch OAuth Token.OPENAI_ORG
: Your OpenAI Organization IDOPENAI_SECRET_KEY
: You need to have access to the GPT OpenAI API. Obtain an API key from OpenAIBOT_PREPROMPTS
: Enter the pre-prompt text for your robot. Its personality or whatever you want, what you expect from it.
Build and run the index.js
npm run build
npm run start
The bot listens to incoming messages in the Twitch chat and responds whenever it is mentioned using @your-bot-username. Here's how the main logic works:
The bot listens to incoming messages from Twitch chat using TMI.js.
When a message is received, it checks if it contains a mention to the bot's username.
If a mention is found, it then sends the user's message as a prompt to the GPT OpenAI API, along with a system message indicating that the bot should respond to the mentioned user.
The GPT OpenAI API generates a response based on the user's message and the system message.
The bot receives the response from the GPT OpenAI API and sends it back to the Twitch chat as a message.
The GPT model used for generating responses is 'gpt-3.5-turbo', and the maximum number of tokens used in the response is set to 75.
Please note that the response generated by the GPT model might not always be appropriate or accurate. It's important to moderate and verify the bot's responses to ensure a positive user experience.
This project is licensed under the MIT License - see the LICENSE file for details. Acknowledgments
This README was generated by ChatGPT, feel free to do any pull-request you want.