pedrojlazevedo / twitch-chatgpt

ChatGPT Implementation for Twitch Streamers
67 stars 1.63k forks source link
chatgpt

ChatGPT Twitch Bot Documentation

Important Notice: Cyclic is no longer supported for deployment. Please use Render for deploying this bot.

Your support means the world to me! ❤️

Buy me a coffee to support me

Join our Discord community:

https://discord.gg/pcxybrpDx6


Overview

This is a simple Node.js chatbot with ChatGPT integration, designed to work with Twitch streams. It uses the Express framework and can operate in two modes: chat mode (with context of previous messages) or prompt mode (without context of previous messages).

Features


Setup Instructions

1. Fork the Repository

Login to GitHub and fork this repository to get your own copy.

2. Fill Out Your Context File

Open file_context.txt and write down all your background information for GPT. This content will be included in every request.

3. Create an OpenAI Account

Create an account on OpenAI and set up billing limits if necessary.

4. Get Your OpenAI API Key

Generate an API key on the API keys page and store it securely.

5. Deploy on Render

Render allows you to run your bot 24/7 for free. Follow these steps:

5.1. Deploy to Render

Click the button below to deploy:

Deploy to Render

5.2. Login with GitHub

Log in with your GitHub account and select your forked repository for deployment.

6. Set Environment Variables

Go to the variables/environment tab in your Render deployment and set the following variables:

6.1. Required Variables

6.2. Optional Variables

6.2.1. Nightbot/Streamelements Integration Variable
6.2.2. All Modes Variables

6.3. Twitch Integration Variables

7. Text-To-Speech (TTS) Setup

Your Render URL (e.g., https://your-twitch-bot.onrender.com/) can be added as a widget to your stream for TTS integration.


Usage

Commands

You can interact with the bot using Twitch chat commands. By default, the command is !gpt. You can change this in the environment variables.

Example

To use the !gpt command:

!gpt What is the weather today?

The bot will respond with an OpenAI-generated message.

Streamelements and Nightbot Integration

Streamelements

Create a custom command with the response:

$(urlfetch https://your-render-url.onrender.com/gpt/"${user}:${queryescape ${1:}}")

Nightbot

Create a custom command with the response:

!addcom !gptcmd $(urlfetch https://twitch-chatgpt-bot.onrender.com/gpt/$(user):$(querystring))

Replace your-render-url.onrender.com with your actual Render URL. Replace gptcmd with your desired command name. Remove $(user): if you don't want to include the username in the message sent to OpenAI.

Support

For any issues or questions, please join our Discord community.

Thank you for using the ChatGPT Twitch Bot! Your support is greatly appreciated. ☕ Buy me a coffee


Important Notice

Cyclic is no longer supported for deployment. Please use Render for deploying this bot.