Ensure you have setup your environment and configuration file before continuing,
WARNING: The configuration file config.json
files will contain sensitive information. Do not share this information.
- config.json
- Where to get the data
- Setting up your commands
- Channel point reward redemptions
- Add users to the chat user exclusion list
- Add commands to the chat command inclusion list
The configuration file is located in the root directory of the project. It is a JSON file and contains several configuration options. It is worth your time to read through the configuration file to understand what different features are available and how to configure them.
You can toggle several features in the features configuration in config.json
. For example, if you would like to greet users on their first message, ensure first_message_handler
is set to true, thus enabled.
Interval commands are commands that are executed on a regular interval. For example, you can set up a command that says "Hello World" every 5 minutes.
You can find more information about these features in the interval commands configuration guide
Enabling this feature will allow the bot to handle Bit events. It's recommended to personalise the reaction to your liking.
The code for this handler is located in bitHandler.ts
Enabling this feature will allow the bot to handle Sub events. It's recommended to personalise the reactions to different sub events to your liking.
The code for this handler is located in subHandler.ts
Enabling this feature will allow the bot to handle First Message events. It's recommended to personalise the reaction to first message events to your liking.
The code for this handler is located in firstMessageHandler.ts
Enabling this feature will allow the bot to handle First Message of Stream events. This message is sent on the first message of a user per stream. By default this message is not set, but the user can edit it by using the !welcome
command.
The code for this handler is located in firstMessageOfStreamHandler.ts
The code for the welcome command is located in welcome.ts
Enabling this feature will allow the bot to handle Returning Chatter events. This message is sent when a user sends a message and Twitch includes the returning chatter flag in the message. It is recommended to personalise the reaction to returning chatter events to your liking.
The code for this handler is located in returningChatterHandler.ts
Enabling this feature will allow the bot to interpret commands in chat and run them. These commands are stored in the commands.json
file. See the commands configuration guide for more information.
Enabling this feature will allow the bot to handle built in commands. Built in commands are commands that written in code. The list of built in commands that will be loaded is stored in the builtInCommands array found in botCommands.ts.
Enabling this feature will allow the bot to handle subscription events. The default subscription events are:
- Follows
- Raids
- Redeems
- Stream Online Notifications
- Stream Offline Notifications
You can edit the handling of subscription events in twitchEventSubHandler.ts and twitchEventSubWebsocket.ts
When enabled the repeat message handler will automatically use TTS to say the message which has been repeated n amount of times by users in chat.
The listed scopes are relevant to the existing commands in the repository. If you would like to add new features with more in-depth API interactions then you should adjust the scopes accordingly.
Ensure you have setup your Twitch developer account and application by following the Twitch setup guide
Note: The required scopes are chat:read
, chat:edit
, channel:manage:redemptions
, channel:read:redemptions
, moderator:manage:banned_users
, channel:manage:broadcast
and moderator:read:followers
.
Fill in the required details in config.json
for Twitch, leaving the auth_code
field empty. We suggest your redirect_uri
is set to http://localhost:3000
. The bot will listen on whichever port you specify in the redirect_uri
.
Once set, run the server with npm run start
within the server directory. The bot will automatically retrieve and update your Twitch auth_code
. You will need to restart the server once more after the auth_code
is updated.
To get the auth_code construct your URL and enter it into the browser. Here's an example:
https://id.twitch.tv/oauth2/authorize?response_type=code&client_id=<your_client_id>&redirect_uri=<your_redirect_uri>&scope=channel%3Amanage%3Aredemptions+channel%3Aread%3Aredemptions+moderator%3Amanage%3Abanned_users+chat%3Aread+chat%3Aedit+moderator%3Aread%3Achatters+channel%3Amanage%3Abroadcast
Once you open this and authorize access, it will redirect you. Take the auth code from the new URL.
Ensure you have setup your Spotify developer account and application by following the Spotify setup guide
Note: The required scopes are user-read-currently-playing
, user-read-playback-state
, and user-modify-playback-state
.
The country code is used to help the bot determine if songs are available in the Spotify account's country.
Use the Authorization Code Flow
Fill in client_id
, client_secret
and grant_type
fields in config.json
for Spotify, leaving the auth_code
field empty. We suggest your redirect_uri
is set to http://localhost:3000
. The bot will listen on whichever port you specify in the redirect_uri
.
To get the auth_code construct your URL and enter it into the browser. Here's an example:
https://accounts.spotify.com/authorize?response_type=code&client_id=<your_client_id>&redirect_uri=<your_redirect_uri>&scope=user-read-currently-playing%20user-read-playback-state%20user-modify-playback-state
Once you open this and authorize access, it will redirect you. Take the auth code from the new URL and paste it into the auth_code
field in config.json
.
You only need to toggle the enabled flag to true
. Internally the bot will use the Twitch account's ID to find your SevenTV ID.
You only need to toggle the enabled flag to true
. Internally the bot will use the Twitch account's ID to find your BTTV ID.
You only need to toggle the enabled flag to true
. Internally the bot will use the Twitch account's ID to find your FFZ ID.
To get the session_id
to use the TikTok voices in the !tts
command you need to create a TikTok account and extract the session_id
from your browser. This can be done by accessing the cookies in your browser and copying the value of the session_id
cookie.
It is recommended not to change the commands stored in the commands.json
manually. Instead, use the !addcommand
command when the bot is running to create commands that play sounds, emit events, and more. You can find more information about these features in the commands configuration guide
A lot of the power of the bot comes from the commands that you set up. While a large majority of the commands you may want to add can be done through the !addcommand
command, there are some commands that are hard-coded into the bot. These commands are more powerful and can be used to connect to APIs and perform more complex actions. For example the TTS command which calls out to different TTS providers.
The bot can automatically handle channel point reward redemptions.
You can find more information about these features in the channel point rewards configuration guide
If you would like certain users' messages to be filtered from the chat client, you can add them to the chat-user-exclusion-list.txt
file in the root directory of the project.
Each username should be on a new line.
For example, to exclude the users troll
and troll2
from chat commands, you would add the following lines to the file:
troll
troll2
Note that chat-user-exclusion-list.txt
will be created automatically when you run the server for the first time.
By default, messages the start with !
are not sent to the chat client. If you would like certain commands to appear in the chat overlay, you can add them to the chat-command-inclusion-list.txt
file in the root directory of the project.
Each command should be on a new line.
For example, to add the !tts
and !hello
commands to the chat command inclusion list, you would add the following lines to the file:
tts
hello
Note that chat-command-inclusion-list.txt
will be created automatically when you run the server for the first time.