YouTube Integration
Integrate YouTube Live with FaustBot for chat, Super Chats, memberships, and more.
Overview
FaustBot connects to YouTube Live via the YouTube Data API and Live Streaming API, providing access to:
Live Chat
Read and send messages in your live chat.
Super Chats
Respond to Super Chats and Super Stickers.
Memberships
Welcome new members and track milestones.
Stream Control
Update title, description, and category.
YouTube Live Required
YouTube integration requires an active YouTube Live stream. Make sure you have YouTube Live enabled on your channel before connecting.
Connecting Your Account
Open YouTube Settings
Click YouTube in the sidebar to open the YouTube integration page.
Connect Your Account
Click Connect Account and sign in with your Google account. Make sure to select the account associated with your YouTube channel.
Grant Permissions
FaustBot requires permission to:
- View your YouTube account
- Manage your YouTube Live streams
- Read and send live chat messages
Start Streaming
FaustBot will automatically detect when you go live and connect to your chat. Ensure your stream is live before testing triggers.
Available Triggers
Chat Events
Chat Message Any message in live chatFirst Message User's first message in the streamMonetization Events
Super Chat Paid message with amount and currencySuper Sticker Paid sticker with detailsNew Member New channel membershipMember Milestone Membership anniversary messageGift Membership Gifted membership to another userStream Events
Stream Started Live stream went onlineStream Ended Live stream went offlineSubscriber New channel subscriberEffects
Send Message
Send a message to live chat.
Delete Message
Remove a message from chat.
Timeout User
Temporarily ban a user from chat.
Ban User
Permanently ban a user from chat.
Update Title
Change the stream title.
Update Description
Modify stream description.
Variables
| Variable | Description |
|---|---|
%user% | YouTube channel name |
%displayName% | Display name |
%userId% | YouTube channel ID |
%message% | Chat message text |
%isMember% | Whether user is a channel member |
%isModerator% | Whether user is a moderator |
%amount% | Super Chat amount |
%currency% | Super Chat currency code |
%formattedAmount% | Formatted amount with currency symbol |
%memberLevel% | Membership tier name |
%memberMonths% | Total membership months |
API Limitations
YouTube's API has some limitations compared to Twitch:
Rate Limits
- Chat messages are polled every few seconds (not real-time WebSocket)
- API quota limits apply to your project
- Heavy usage may require increasing quota in Google Cloud Console
Event Delays
- Some events may have 5-30 second delay due to polling
- Super Chats are generally faster than regular messages
- Subscriber notifications may be delayed by several minutes
Optimizing Performance
To minimize delays, ensure FaustBot is the primary app polling your chat. Avoid having multiple bots or tools reading the same chat simultaneously.
Scripting API
Access YouTube Live features from your scripts:
Handling Super Chats
# Handle YouTube Super Chats
def Execute():
user = args["displayName"]
amount = float(args["amount"])
currency = args["currency"]
formatted = args["formattedAmount"]
message = args.get("message", "")
# Log the Super Chat
CPH.LogInfo(f"Super Chat from {user}: {formatted}")
# Scale reaction based on amount
if amount >= 100:
CPH.RunAction("Massive Super Chat Alert")
CPH.ObsSetScene("Super Chat Celebration")
elif amount >= 20:
CPH.RunAction("Big Super Chat Alert")
else:
CPH.RunAction("Super Chat Alert")
# Thank the supporter
CPH.SendMessage(f"Thank you {user} for the {formatted} Super Chat!")
return TrueMember Events
# Handle YouTube member events
def Execute():
user = args["displayName"]
event_type = args.get("eventType", "new")
level = args.get("memberLevel", "Member")
months = int(args.get("memberMonths", 1))
if event_type == "new":
CPH.LogInfo(f"New member: {user} at {level}")
CPH.RunAction("New Member Alert")
CPH.SendMessage(f"Welcome {user} to the {level} family!")
elif event_type == "milestone":
CPH.LogInfo(f"{user} hit {months} months!")
if months >= 12:
CPH.RunAction("Annual Member Alert")
CPH.SendMessage(f"{user} has been a member for {months} months!")
elif event_type == "gift":
recipient = args["recipientName"]
CPH.LogInfo(f"{user} gifted membership to {recipient}")
CPH.SendMessage(f"{user} gifted a membership to {recipient}!")
return TrueStream Management
# Manage YouTube stream settings
def Execute():
command = args.get("command", "")
if command == "!title":
new_title = args.get("input", "")
if new_title:
CPH.YouTubeSetStreamTitle(new_title)
CPH.SendMessage(f"Stream title updated to: {new_title}")
else:
current = CPH.YouTubeGetStreamInfo()
CPH.SendMessage(f"Current title: {current['title']}")
elif command == "!category":
category = args.get("input", "")
if category:
CPH.YouTubeSetStreamCategory(category)
CPH.SendMessage(f"Category changed to: {category}")
elif command == "!stream":
info = CPH.YouTubeGetStreamInfo()
if info["isLive"]:
viewers = info["viewerCount"]
likes = info["likeCount"]
CPH.SendMessage(f"Live with {viewers} viewers and {likes} likes!")
else:
CPH.SendMessage("Stream is currently offline")
return TrueChat Moderation
# Moderate YouTube live chat
def Execute():
user = args["displayName"]
user_id = args["userId"]
message = args["message"].lower()
is_mod = args.get("isModerator", False)
is_member = args.get("isMember", False)
# Skip moderators and members
if is_mod or is_member:
return True
# Check for spam patterns
spam_patterns = ["buy followers", "free money", "click here"]
for pattern in spam_patterns:
if pattern in message:
CPH.LogInfo(f"Spam detected from {user}")
CPH.YouTubeDeleteMessage(args["messageId"])
CPH.YouTubeTimeoutUser(user_id, 300)
return False
# Link filter for non-members
if "http" in message or "www." in message:
CPH.YouTubeDeleteMessage(args["messageId"])
CPH.SendMessage(f"@{user} links are only allowed for members.")
return False
return TrueSee the full API reference for all available methods.