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

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.

  1. 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.
  2. Enable the API. Open https://console.cloud.google.com/apis/library/youtube.googleapis.com, check that the project above is selected, and select Enable.
  3. Set up the consent screen. Open APIs & Services > OAuth consent screen (Google Auth Platform) and select Get started.
  4. 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.
  5. In Data Access > Add or remove scopes, check youtube.readonly and save.
  6. 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.
  7. Create the client. Open Clients > Create client, set the application type to Desktop app, and select Create.
  8. Do not register a redirect URI. The Desktop app type allows 127.0.0.1 addresses automatically.
  9. 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.
  10. A new client can take a few minutes to become active at Google. If you sign in right away and get an invalid_client error, wait and try again.
  11. In Unreal, open Tools > CBM > Live Chat…. In the YouTube section, expand OAuth Client, enter the Client ID and Client Secret, and press Save.
  12. 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).
  13. 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:

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.

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.