Warning

This is an Advanced guide. It assumes reasonable familiarity with both Keysight and being able to navigate files and copy/paste things.

Welcome! This guide covers how to use the websockets found under the System > Websockets menu to remotely control Keysight using Twitch chat messages. We will be using a pre-packaged tool created by Cellko bundled with Keysight.

Info

Historically, websocket servers and chat integration have been the responsibility of users. This pre-packaged tool is limited, but removes the need for a development environment or guides such as this excellent one from typefeisterjoel➚ to get things working. But if you need more functionality, the source code for Cellko's tool is open source and available here➚ and could serve as a good basis for further development.

Requirements

Limitations

  • This tool is exclusively built for Twitch, and will not work for Youtube chat or any other streaming platforms
  • You cannot use channel points to control Keysight via this guide
  • There is no queueing system, so depending on who you allow to trigger commands, this tool is open to spam abuse

Process

Make sure that the Inbound websocket is disabled in Keysight before starting!

Disable inbound

Warning

While a MacOS version of the chat control tool is built and provided, this is entirely untested and I have no idea how to guide you on how to "open" it. If you're a MacOS user following this guide, get in touch via Discord and let me know how it works, and I'll update this page!

Copy the tool's files

Locate the tool's executable file and copy it into a new folder somewhere for safe keeping. The tool can be downloaded here⬇, or found in your Keysight install files under the \Extra Resources folder. On Windows, this would be:

  • C:\Program Files (x86)\Steam\steamapps\common\Keysight\Keysight\Extra resources\Twitch Chat Control\KeysightTwitchChatControl.exe

The easiest way to get here is just to right click on Keysight in your Steam library, hover over "Manage" and click "Browse local files".

Info

You must place the tool somewhere that does not require administrator access to create files or you must flag the tool to run with admin privileges. Basically, just don't put the tool in Program Files; somewhere like Documents is fine.

Warning

Do not use the tool in the default location. This will work if you give the tool admin privileges, but any hotfix patches for Keysight run the risk of deleting your configuration for it!

Authenticate

Run the .exe. If you get a "Windows SmartScreen has defended..." message, just hit "More info" and "Run anyway". Also allow the tool to use your internet connection!

When you first run the tool, you will be prompted to authenticate an account. An account must be authenticated in order to listen in to the given account's Twitch chat, and to send response messages back into chat (if desired).

Auth

Simply open the default browser with the Enter key. This should prompt you to authorize "Keysight Chat Control":

Login

Click "Authorize". Done! Chat control will now listen in to the account shown in the authorization screen (presumably your main Twitch account that you keep logged in all the time), and use that account to send messages.

To log in with a different account, select "Incognito mode" or a browser you keep your bot account logged in via (I use Edge to keep Egglybot logged in, so I can authenticate tools by opening the auth URL in Edge).

Once your bot account is authorized, close the KeysightTwitchChatControl.exe console command window to shut the tool down. Next, right click on the tool and create a shortcut. After the .exe path, add --channel=Egglyberts (substituting "Egglyberts" for whatever channel you want). Now, only launch the chat control tool using this shortcut!

Edit commands

You should now have a commands.json and token.json file created next to the .exe. If you do not, something has gone wrong, and you may not be running the tool in a location where it has write-permission!

Now, double click command-editor.html. This will open a web browser tab with the command editing interface:

Command editing

Click "Choose file" and navigate to commands.json to begin editing it. This is filled out with a default setup that allows for seed-based randomisation and switching to the default presets bundled with Keysight. Breaking down each field:

  • Name: Internal name of the command
  • Triggers: This is the list of trigger words that chat control listens for to execute this command. These are split by ,, allowing multiple triggers for the same command
  • Message: This is the exact message sent to Keysight, and must match something set up via Keysight's Inbound websocket. If blank, no message is sent to Keysight and any success/fail/args responses will be printed to chat
  • Success reply: This message is printed back into chat using the logged-in account when the command executes successfully and there has been a response from Keysight. If blank, no message is printed back into chat
  • Insufficient permissions reply: This message is printed if a chatter attempts to use a command they do not have permission to use. If blank, no message is printed back into chat
  • Insufficient args reply: This message is printed if a field uses $msg, but the chatter has not provided any text after the triggering command. Pretty much only used for seed randomisation commands

There are also some toggles on the right for permissions. These operate as OR, so as long as a chatter matches one one the ticked permissions, they will be allowed to execute the given command. The broadcaster can always execute commands, so leaving all permissions unticked makes a command streamer-only.

Wildcards

There are a few special keywords that allow for dynamic message content:

  • $usr - Becomes @username with the username of whoever triggered the command
  • $msg - Becomes [message content] minus the triggering command (eg. for the chat message: !seed portraits, using $msg becomes portraits)
  • $cmd - Becomes the Name of the command being triggered
  • $res - Becomes the response message printed back out of Keysight. Less flexible than specifying your own response message.

Saving command edits

The "Save JSON" button will provide you an updated commands.json file to your Downloads folder. Simply move that file and overwrite the commands.json found adjacent to KeysightTwitchChatControl.exe and the tool's console should show that the file has been updated (no need to restart the tool!).

Enable Keysight websocket

Inside Keysight, simply head to System > Websockets and enable the Inbound websocket. Make sure your Address is set to http://localhost:3000 and Broadcast response messages is enabled:

Enable websocket

Over in the tool console, you should now see a connected socket.io client:

Connected client

Test things

Go type some commands in chat! The last-received Message from commands.json is displayed here:

Message received

Remember that if you add or change any commands, you will need to add matching actions in Keysight. Some things to double check if you run into issues:

  • The tool is running, and the console shows: valid token / socket.io server started / commands updated / bot connected / socket.io client connected.
  • You moved the newly created commands.json to overwrite the commands.json next to the tool .exe after editing some commands
  • You have matching triggers in Keysight to any Message fields from commands
  • The websockets are enabled in Keysight

Warning

Be cautious when toggling websockets on and off in Keysight. This can have some connectivity issues with the tool and you may need to reboot it, thanks to the dubious quality of the Socket.IO plugin being used in Unreal Engine.

Hard-coded special commands

There is one pair of hard-coded commands: !responses off and !responses on. These are broadcaster and mod-only, and will disable/re-enable any Success / Failure / Insufficient args responses from commands being printed to chat. This is aimed at larger streamers who may want to turn off responses temporarily in the case of lots of activity.

Extra ideas for chat control implementations:

See this page for a full breakdown of what websockets can do in Keysight, but consider the following:

  • Creatively gate commands behind different permissions. For example, "OD randomize (seed)" is likely to give insane and flashy presets, and could be a T2/T3 incentive
  • Use blank Message with "Everyone" permission to have simple print-info-to-chat commands relevant to your Keysight chat control implementation, so all those commands exist via one tool
  • Be careful with using Insufficient Permissions Reply. Telling people they're poor and not a T2 sub and therefore can't do fun stuff is probably not the most positive message, and it might be better to say nothing
  • Set up lots of aliases for your presets to account for spelling mistakes or "I just want things red, so I am going to type !red" types of chatters
  • Use $usr as an alternative to $msg for seed randomisation, to give chatters a quick way of using their own username as a seed