Live Chat Setup
The CBMKitChat module reads viewer chat from streaming platforms and passes it to the character. Live chat is used only in the Broadcast run type. In the Companion run type, the chat module does not start (see COMPANION.md). For the rest of the broadcast setup, see BROADCAST.md.
1. Live Chat window
Open Tools > CBM > Live Chat… in the editor. The menu item is shown only in the Broadcast run type.
| Section | What to enter |
|---|---|
| YouTube | Connect a YouTube account (section 2.1) |
| CHZZK | Shown as Coming soon. Cannot be enabled in this version |
| TikTok | Shown as Coming soon. Cannot be enabled in this version |
| Twitch | Check Enable and enter the Channel Name |
| Other Platforms (Relay) | Check Enable and set the Port (section 2.3) |
Press Save. Changed values are written to your project's Config/DefaultGame.ini. If the game is running, the chat sources reconnect with the new values and the window shows "Saved and applied to the running game."
While the game is running, each section shows its connection state on the right:
| State | Meaning |
|---|---|
| Receiving chat | Connected and reading chat |
| Connecting | Connection in progress |
| Waiting to reconnect | Connection lost; a retry is scheduled |
| Disconnected | Not connected |
| Off | The source is not enabled |
The other settings are in Project Settings > Plugins > CBM Chat.
| Setting | Default | Meaning |
|---|---|---|
bAutoStart |
On | When the game starts (Broadcast run type), connect all enabled sources |
bForwardToConversation |
On | Pass filtered chat to the character. Off = chat is only received (for your own UI) |
RecentMessageCapacity |
100 | Number of recent messages kept for GetRecentMessages |
2. Platforms
2.1 YouTube Live: account connection (recommended)
The plugin does not include an OAuth client. Each user creates one OAuth client once with their own Google account and enters it in the plugin. It is free and needs no billing information. Google Cloud menu names can change.
- Create a project. Sign in at https://console.cloud.google.com, open the project picker at the top, select New Project, enter a name (for example
CBM Chat), and select Create. - Enable the API. Open https://console.cloud.google.com/apis/library/youtube.googleapis.com, check that the project above is selected, and select Enable.
- Set up the consent screen. Open APIs & Services > OAuth consent screen (Google Auth Platform) and select Get started.
- Enter an app name (for example
CBM Chat) and a user support email. Set the audience to External. Enter a contact email, accept the policy, and select Create. - In Data Access > Add or remove scopes, check
youtube.readonlyand save. - In Audience, select Publish app to change the publishing status to In production. You do not need to submit the app for verification.
- "Testing" status: only accounts added as test users can sign in, and the connection expires every 7 days and must be made again.
- "In production" without verification: sign-in shows a "Google hasn't verified this app" warning. Select Advanced, then Go to (app name). Up to 100 users can sign in, and the connection does not expire.
- Create the client. Open Clients > Create client, set the application type to Desktop app, and select Create.
- Do not register a redirect URI. The Desktop app type allows
127.0.0.1addresses automatically. - Save the Client ID (
...apps.googleusercontent.com) and Client secret (GOCSPX-...) with Download JSON. The client secret is shown only when the client is created. - A new client can take a few minutes to become active at Google. If you sign in right away and get an
invalid_clienterror, wait and try again. - In Unreal, open Tools > CBM > Live Chat…. In the YouTube section, expand OAuth Client, enter the Client ID and Client Secret, and press Save.
- Press Connect YouTube Account. In the browser, choose the account and channel you stream on (brand accounts included) and allow access. The window shows "Sign in in your browser." during sign-in. When it shows Connected channel: (channel name), the connection is done. The browser returns the sign-in result to
http://127.0.0.1:18060/youtube/callback(YouTubeSignInPort). - While connected, start a live stream. The plugin finds that channel's active live broadcast (
liveBroadcasts.list, 1 quota unit) and reads its chat. If there is no live broadcast, it searches again with backoff (2 seconds up to 60 seconds).
Notes:
- When an account is connected, YouTube chat is read even if
bEnableYouTubeis off. - Disconnect revokes the token at Google and deletes it. Connect Another Account replaces the connected account.
- The OAuth client and the sign-in token are stored per Windows user in
%LOCALAPPDATA%/CBMKit/youtube_account.json, not in your project. The client secret and token are encrypted with Windows DPAPI. They are not included when you commit or package your project. On another PC or another Windows user, enter the client and connect again. - Quota is charged to the Google Cloud project that owns the OAuth client. If you save a different client ID or client secret, the existing connection is removed.
- If
YouTubeVideoIdis set, the chat of that video is read whether or not an account is connected. - The Live Chat window is editor-only. To add a connect button to a packaged game with UMG, use these on
UCBMChatSubsystem:ConnectYouTubeAccount,DisconnectYouTubeAccount,GetYouTubeAccountState,GetYouTubeChannelTitle,GetYouTubeAccountError, and the eventOnYouTubeAccountChanged.
2.2 YouTube Live: API key (when no account is connected)
Set these in Project Settings > Plugins > CBM Chat > YouTube.
| Setting | Meaning |
|---|---|
bEnableYouTube |
Turns on the YouTube source |
YouTubeApiKey |
YouTube Data API v3 key. Used only when no account is connected |
YouTubeVideoId |
Live video ID or URL (recommended) |
YouTubeChannelId |
Channel ID. Used to search for the live video when YouTubeVideoId is empty |
YouTubeMinPollSeconds |
Lower limit of the poll interval. Default 6 |
The API key is stored in plain text in Config/DefaultGame.ini. Do not commit it to source control and do not ship it in a public build.
Data API v3 quota (default 10,000 units per day):
| Call | Cost |
|---|---|
videos.list |
1 unit |
search.list (live search by channel ID) |
100 units. On reconnect, the cached video ID is used first |
liveChat/messages.list |
About 5 units per call |
At a 6-second poll interval, 10,000 units can run out in about 2 hours. For long streams, raise YouTubeMinPollSeconds or request a quota increase from Google. Messages sent before the connection are skipped.
Super Chat and Super Sticker are handled as donations.
2.3 Twitch
bEnableTwitch, TwitchChannel. Reads chat over anonymous (justinfan) IRC. Read-only; no token is needed. Bits (cheers) are handled as donations with the currency BITS.
2.4 Other platforms: LocalHttp (chat bot or relay program)
For platforms that have no built-in connector, a chat bot or relay program sends chat to this address. The platform value it sends goes into the conversation log and the prompt as-is.
- Settings:
bEnableLocalHttp(default on),LocalHttpPort(default 18040). The server binds to127.0.0.1only. POST /chatwith a JSON body:json {"platform":"x","user":"name","message":"text","donation":1000}donationcan also be{"amount":1000,"currency":"KRW"}. Optional fields:user_id,channel,moderator,subscriber.userandmessageare required. The response is{"ok":true}.GET /healthreturns{"status":"ok","service":"livechat"}.- Test with the script shipped in the plugin:
python Plugins/CBMKit/Content/Python/cbmkit_localai/tools/send_chat.py "hello" --user tester [--donation 1000] [--port 18040]For an engine install of the plugin, use the path of the plugin folder in your engine.
3. Filters (which messages the character answers)
Each chat message goes through these steps in order. A message that fails a step is not answered.
| Step | Settings |
|---|---|
| 1. Ignore messages that start with a prefix | IgnorePrefixes (default !, /) |
2. Remove URLs and emoticon codes such as {:d_123:} |
bStripUrls, bStripEmotes |
3. Ban words: drop the message, or replace the word with * |
BanWords, bDropOnBanWord |
| 4. Length: drop below the minimum, cut above the maximum | MinMessageLength (2), MaxMessageLength (150) |
| 5. Trigger words: answer only messages that contain one | bRequireTrigger, TriggerWords |
| 6. Per-user cooldown | PerUserCooldownSeconds (20) |
| 7. Answer one message in N | RespondToOneInN (1) |
| 8. Maximum replies per minute | MaxRepliesPerMinute (0 = no limit) |
When bDonationsBypassFilters is on (default), donations skip steps 5 to 8. Length and ban words still apply. Donations are passed with DonationPriority (default 100). Regular chat uses ChatPriority (default 0).
4. Blueprint
UCBMChatSubsystem:
| Function or event | Use |
|---|---|
Start, Stop |
Connect or disconnect all sources |
ApplySettings |
Rebuild the sources from the CBM Chat settings |
FindSource, AddSource, RemoveSource, GetSources |
Manage sources |
GetRecentMessages |
Recent messages |
InjectMessage |
Send a message as if it came from chat |
OnChatMessage |
Every received message, before filters. For UI |
OnSourceStateChanged, OnSourceError |
Connection state and errors |
UCBMChatSource is Blueprintable. To make a custom source, create a child Blueprint, implement OnConnectRequested, and call EmitMessage, NotifyConnected, and NotifyConnectionLost. Add it with AddSource.