Skip to content

AST Functions Reference

Browse every $(...) function for custom commands—users, text, Twitch data, moderation, polls, predictions, roulette, TTS, triggers, clips, widgets, and EventSub—with arguments, access, and plan rules.

Functions are the $(...) calls you drop into a custom command’s reply. Use them to pull live data (the caller’s name, stream title, or follower count), trigger channel actions (changing the title, starting a raid, running a poll), or steer execution (pausing or exiting a loop). Below you’ll find every common function, what it returns, and who can run it.

  1. Open Commands in the navbar and create a new command or edit an existing one.
  2. Insert a function right where you want its output—for example, Welcome $(user)!.
  3. Save and test with a harmless call like $(random 10) first; add channel-modifying functions only once the reply reads the way you want.
  • Your own commands follow the access level set on the command itself. Function role metadata does not normally add a second gate, though individual functions may still enforce context rules. For instance, if you give everyone access to a command that calls $(ban ...), regular viewers can fire it—always match command access to the power of the actions inside.
  • AI chat requests through the bot personality are checked differently: when a viewer asks the AI assistant to perform an action, the minimum role listed in the Access column applies (Moderator is level 7; Editor is level 8).
  • Plans: Temporary VIP and moderator durations require Premium or Pro, and saving to database variables (%(*name ...), %(**name ...)) also requires Premium or Pro. Roulette functions work on Free.
FunctionDescriptionExample
$(user)Username of whoever ran the command$(user)
$(touser)Everything typed after the command, or the caller’s name if left blank (preserves a leading @ when typed)!hug @ronchi → @ronchi
$(randomuser)Picks a random chatter from the channel list; falls back to the caller if the list is empty, or returns an error message if the lookup fails$(randomuser)
FunctionDescriptionExample
$(random)Random whole number from 0 to 99$(random)
$(random N)Random whole number from 0 to N-1$(random 10) gives 0 to 9
FunctionDescriptionExample
$(upper text)Converts text to uppercase$(upper hello) → HELLO
$(lower text)Converts text to lowercase$(lower HELLO) → hello
$(title text)Capitalizes the first letter of every word after lowercasing the rest$(title hello world) → Hello World
$(capitalize text)Capitalizes the first character only$(capitalize hello) → Hello
$(trim text)Strips leading and trailing spaces$(trim " hi ") → hi
$(length text)Returns the character count$(length hello) → 5
$(slice start [end] text)Extracts a substring by index (negative numbers count from the end)$(slice 0 5 hello world) → hello
$(replace search replacement text)Replaces every literal match (plain text only, no regex patterns)$(replace o 0 foo) → f00

Wrap multi-word search or replacement strings in double quotes: $(replace "old text" "new text" the old text here).

These pull live information from Twitch and are open to everyone.

FunctionDescriptionExample
$(twitch.live)Returns true while live, or false when offline or unknown—handy in conditionals$(twitch.live)
$(twitch.title)Current stream title, or No title set$(twitch.title)
$(twitch.game [target])Current or most recently played Twitch category for your channel or an optional target; returns No game set for your own channel if blank (Twitch API field)$(twitch.game)
$(twitch.viewers)Current chatter count, or the event viewer count when supplied by an event$(twitch.viewers)
$(twitch.subs)Current subscriber count$(twitch.subs)
$(twitch.follows)Current follower count$(twitch.follows)
$(twitch.channel [target])Display name for your channel or an optional target$(twitch.channel)
$(twitch.login [target])Lowercase login for your channel or an optional target$(twitch.login)

With twitch.channel, twitch.login, and twitch.game, omitting target reads your own channel. When provided, target must be a single Twitch login (an optional leading @ is accepted). Empty, invalid, unknown, or failed lookups return blank text; for targeted twitch.game calls, a channel with no reported category also returns blank. Matching login syntax does not verify the account exists. Repeated lookups for the same target are cached within a single command run.

The roles listed here are enforced only when the bot personality calls these functions from AI chat. Inside your own custom commands, your command’s access setting controls who can run them, even non-moderators.

FunctionWhat it doesArgumentsAccess (AI chat)
$(vip) or $(add.vip)Grants VIP; include days to make it temporaryusername [days]Moderator
$(unvip)Removes VIPusernameModerator
$(ban)Bans a user, or times them out when seconds are supplied (up to 604800 seconds / 7 days)username [seconds]Moderator
$(ban.mod)Strips moderator status, then bans or times the user out; pass true to restore mod status after the timeoutusername seconds [true|false]Editor
$(mod) or $(add.mod)Grants moderator; include days to make it temporaryusername [days]Editor
$(unmod)Removes moderatorusernameEditor
$(warn)Issues an official Twitch warning (reason: 1–500 characters)username reasonModerator
$(clear.chat)Wipes chatnoneModerator
$(emoteonly)Toggles emote-only mode; passing seconds turns it back off automatically once that duration expires[seconds]Moderator
$(permit)Lets users bypass moderation filters (caps, links, emote spam, blacklist) temporarily; with no arguments, permits everyone for 60 seconds[username] [seconds]Moderator
$(bot.mode attack)Switches Follow Defense into attack modenoneModerator
$(bot.mode status)Reports the current Follow Defense mode and time remainingnoneModerator

Temporary VIP and moderator durations accept 1 to 365 days and require Premium or Pro. On Free, the role is granted without the timer, so it stays until removed manually. Even on paid plans, the role is granted before validating days, meaning an invalid duration can leave the role active. $(permit) accepts 1 to 600 seconds, and $(ban.mod) always requires a seconds value.

When $(emoteonly) is called with seconds, its auto-off countdown lives in the bot’s memory—if the bot restarts before time runs out, emote-only remains active until switched off manually.

FunctionWhat it doesExample
$(raid channel)Starts a raid to the target login, returning User not found if the login doesn’t exist$(raid targetchannel)
$(unraid)Cancels an outgoing raid and posts Raid cancelled! in chat$(unraid)
$(set.title new_title)Updates the stream title and posts Title updated to: … in chat$(set.title Playing Valorant!)
$(set.game game_name)Sets the category using an exact match first or Twitch’s top search match, then posts Game updated to: … in chat$(set.game Valorant)
$(ad) or $(ad.time)Ad-break length in seconds (0 outside an ad-break event)$(ad)
$(ai prompt)Generates an AI reply to the prompt$(ai tell a joke)

Every function in this table requires moderator access in AI chat except $(ad) and $(ai), which anyone can use.

Wrap the entire title;choices;seconds string in double quotes because ; is reserved syntax, and separate choices with /.

FunctionWhat it doesExample
$(start.poll "title;choice1/choice2;seconds")Launches a native Twitch poll with 2–5 choices; append a fourth field for Channel Points per vote from 0 to 1000000 (defaults to 0, off)$(start.poll "Best map?;Nuke/Mirage;120")
$(get.poll)Summarizes the active poll (or latest poll if none is live) with status and vote totals$(get.poll)
$(end.poll)Ends the active poll immediately while keeping its results for poll.result / poll.tied$(end.poll)
$(cancel.poll)Cancels the active poll with no result, so the Poll ended chat event does not run$(cancel.poll)

Both end.poll and cancel.poll require an active poll. Every function in the table above requires moderator access in AI chat.

Reading a poll

These read functions work across commands, timers, chat event messages, and roulette winner actions. They all read from a shared snapshot of the active poll (or the most recent poll when none is running), keeping multiple calls in the same command consistent. Twitch notifications keep vote totals up to date within a few seconds. If Twitch cannot be reached, they return blank text—except poll.status, which returns unavailable—and never post errors. Anyone can use them in AI chat.

FunctionReturns
$(poll.title)Poll question
$(poll.status)active, ended, canceled, none (no poll), or unavailable
$(poll.options)Option titles as a list in Twitch’s order
$(poll.values)Vote counts in the same order, including Channel Points votes
$(poll.votes option)Votes for an exact title (case-insensitive) or a 1-based number starting at 1; blank if missing or unknown
$(poll.total)Total votes cast, or 0 if nobody voted
$(poll.result)Current leader while active or winner once ended; blank on a tie, zero votes, or cancellation
$(poll.tied)List of options tied for first, or blank if one option leads or the poll was canceled (blank is false in conditions, and the list works in loops)

When nobody votes, every option counts as tied—check poll.total first if you want a separate message for zero votes. A poll that runs to completion, ends early on Twitch, or ends via $(end.poll) has status ended. One canceled with $(cancel.poll) or deleted on Twitch has status canceled: its options and vote counts remain readable, while poll.result and poll.tied return blank.

Wrap the entire title;choices;seconds string in double quotes and separate choices with /.

FunctionWhat it doesExample
$(start.prediction "title;choice1/choice2;seconds")Starts a Channel Points prediction (Twitch accepts 2–10 choices; the bot requires at least 2)$(start.prediction "Will we win?;Yes/No;120")
$(get.prediction)Lists the active or locked prediction with its numbered outcomes$(get.prediction)
$(lock.prediction)Closes betting without picking a winner (a locked prediction remains locked)$(lock.prediction)
$(end.prediction option)Resolves the prediction by exact choice title or 1-based number starting at 1$(end.prediction "No") or $(end.prediction 1)
$(cancel.prediction)Cancels the active or locked prediction without choosing a winner$(cancel.prediction)

Call get.prediction before end.prediction to confirm the question and numbering. end.prediction queries Twitch fresh on each run and rejects unknown numbers or titles that match multiple outcomes.

Reading a prediction

Prediction read functions work in the same contexts and share a saved snapshot just like poll reads. Anyone can use them in AI chat. If Twitch is unreachable, they return blank text—except prediction.status, which returns unavailable—without posting errors.

FunctionReturns
$(prediction.title)Prediction question
$(prediction.status)active, locked (betting closed), ended (winner picked), canceled (points refunded), none, or unavailable
$(prediction.options)Outcomes as a list
$(prediction.values)Channel Points wagered on each outcome, in the same order
$(prediction.points option)Points wagered on an outcome by title or number
$(prediction.users option)Number of viewers who bet on an outcome by title or number
$(prediction.total)Total Channel Points wagered
$(prediction.result)Winning outcome once chosen; blank while active or if canceled

Toggle a channel custom command or Twitch Channel Points reward on or off. AI chat calls require moderator access, while custom commands follow their own access setting.

FunctionWhat it doesExample
$(disable.command "name" [seconds])Turns a command off$(disable.command spoilers 300)
$(enable.command "name" [seconds])Turns a command on$(enable.command spoilers 300)
$(disable.redemption "title-or-id" [seconds])Turns a Twitch reward off$(disable.redemption "Hydrate" 300)
$(enable.redemption "title-or-id" [seconds])Turns a Twitch reward on$(enable.redemption "Hydrate" 300)
  • Names: Matched exactly, ignoring capitalization. For commands, a leading ! is optional. Quote names containing spaces.
  • Commands: Keyword triggers (words without !) cannot be toggled with these functions.
  • Rewards: Applies only to Twitch rewards. If two rewards share the same title, the bot refuses and asks you to pass the reward ID instead.
  • Duration: Accepts whole seconds from 1 to 604800 (seven days). Once time runs out, the item reverts to its previous state—even across a bot restart. Running the same timed toggle again extends its timer, while omitting seconds cancels any pending restore.

Available on Free, Premium, and Pro. Pass a roulette’s alias or ID to target it; only roulette.start and roulette.result can omit the ID to target the active roulette, while show and hide control the active overlay. On success, every function except roulette.result and roulette.add returns blank chat text, and failures return an error message. roulette.add returns the new item’s ID so you can store it in a variable.

FunctionWhat it doesExample
$(roulette.create roulette_id ["Name"])Creates an empty roulette with the default wheel design. IDs must start with a lowercase letter and use letters, numbers, _, or - (uppercase letters are lowercased); Name defaults to the ID. Up to 20 roulettes per channel; a duplicate ID returns Error: roulette.create: Roulette with that name already exists$(roulette.create polls "Poll tie-breaker")
$(roulette.delete roulette_id)Permanently deletes the roulette, its prizes, and its settings—
$(roulette.clear roulette_id)Empties all prizes while keeping the roulette, design, settings, and history intact—
$(roulette.fill roulette_id list)Replaces all prizes in a single save, adding one slot of weight 1 per entry; accepts a list value, list variable, literal list, or quoted labels, and rejects empty lists with no changes$(roulette.fill polls $(poll.tied))
$(roulette.add roulette_id "item label" [multiplier] [weight])Adds a prize where multiplier is copy count (default 1) and weight sets odds per copy (default 1)$(roulette.add giveaways "VIP for a day" 3 10)
$(roulette.remove roulette_id item_id)Removes an item along with every copy of it$(roulette.remove giveaways item_id)
$(roulette.update roulette_id item_id multiplier [weight])Updates an item’s copy count and, optionally, its weight$(roulette.update giveaways item_id 3 10)
$(roulette.shuffle roulette_id)Randomizes slice placement without changing winning odds$(roulette.shuffle giveaways)
$(roulette.switch roulette_id)Sets which roulette is active without altering overlay visibility$(roulette.switch giveaways)
$(roulette.show) / $(roulette.hide)Shows or hides the overlay (hiding does not cancel an active spin)$(roulette.show)
$(roulette.start [roulette_id])Spins the wheel and records a winner$(roulette.start giveaways)
$(roulette.result [roulette_id])Returns the latest winner’s label, or blank if no draw has finished$(roulette.result giveaways)

delete, clear, and fill are refused while any roulette on the channel is spinning, though roulette.add still works and applies to the next spin. Calling roulette.start roulette_id selects that roulette and displays it when the default show-on-start option is enabled.

A saved command runs with the streamer’s authority for anyone permitted to trigger it. Limit commands that delete or empty a roulette to moderators or the streamer.

In AI chat, anyone can call roulette.result, while all other roulette functions require moderator access.

In the roulette editor, you can attach an AST winner action to any item so it runs whenever that item lands. Winner actions have access to %(roulette_id), %(roulette_draw_id), %(roulette_item_id), and %(roulette_item), and run under the channel owner’s plan limits. Restrict who can trigger draws if your winner actions modify channel state.

Each custom command keeps its own persistent counter.

FunctionWhat it doesExample
$(count N)Increments the command’s counter by N and returns the new total$(count 1)
$(count 0)Reads the current total without changing it$(count 0)
$(scount)Adds 1 and returns the new total$(scount)
$(bits)Bits spent in a cheer event (0 outside a cheer)$(bits)
  • Calling $(count) without an inline number reads the chat argument instead—for instance, if the counter sits at 10, a command containing Uses: $(count) drops it to 7 when someone types !uses -3.
  • Signed inline numbers are not supported: $(count -3) evaluates as 0 because inline +/- values are ignored. Use $(count) when you want to apply a signed chat argument rather than hardcoding a negative inline decrement.
FunctionWhat it doesExample
$(create.clip [seconds] [title])Captures a clip and returns its URL (or blank on failure). A leading number from 5 to 60 sets clip length; any other first word starts the title. With no function arguments, it reads the chat command’s arguments. Requires moderator access in AI chat$(create.clip Epic win)
FunctionWhat it doesExample
$(followage [username])Returns how long a viewer has followed—such as 2 months, 3 days, 5 hours—or blank if they don’t follow or aren’t found. When called with no argument, uses the chat command’s argument if supplied, otherwise the caller$(followage ronchi)

These read Twitch event payloads. When the relevant event data isn’t present, text fields return blank or unknown and numeric fields return 0; some fields may also be populated in other event contexts.

FunctionEventReturns
$(raid.channel)RaidDisplay name of the raiding channel
$(raid.login)RaidLogin of the raiding channel
$(raid.viewers)RaidNumber of incoming raiders
$(cheer.amount)CheerBits in the cheer
$(cheer.message)CheerCheer message text
$(sub.tier)SubscriptionPrime, Tier 1, Tier 2, or Tier 3
$(sub.months)SubscriptionCumulative months subscribed
$(gifted.user)Gift subscriptionUsername who received the gift sub
$(hypetrain.progress)Hype TrainCurrent progress toward the goal
$(hypetrain.level)Hype TrainCurrent Hype Train level
$(hypetrain.end)Hype TrainScheduled end time
$(shoutout.channel)ShoutoutChannel that received the shoutout
$(reward.input) or $(redemption.input)Channel Points redemptionText entered by the viewer when redeeming
$(twitch.streak)Chat message with a watch streakWatch streak days (0 if none)
$(twitch.modiversary)Chat message for a moderator anniversaryMonths as moderator (0 if none)
FunctionWhat it doesExample
$(pin [seconds] message) or $(pin.create ...)Sends and pins a chat message for an optional 30 to 1800 seconds; if the first word isn’t a number in that range, the entire argument becomes the message$(pin.create 300 Rules: be kind)
$(pin.update seconds)Updates how long the current pin stays up (30 to 1800)$(pin.update 600)
$(pin.del) or $(pin.delete)Unpins the current message$(pin.del)

Every pin function requires moderator access in AI chat.

TTS must be enabled on your channel for speech to play; otherwise the speaking functions ($(tts), $(tts.standard), $(tts.ai) and the older ones) return TTS is disabled for this channel.

FunctionWhat it does
$(tts message)Uses the channel’s default tier.
$(tts.standard message)Uses Standard with the channel’s Standard voice (Female/Male, or the Other voice) in the channel’s default language. Put a Standard voice ID first to choose a voice: $(tts.standard ef_dora message).
$(tts.quality message)Quality is coming soon. Queues nothing, spends no credits, and replies “Quality voices are coming soon.” (or its Spanish equivalent based on the channel language); it never falls back to Standard.
$(tts.ai message)Uses the default AI voice. To choose a voice, add voice: and a built-in name, favorite nickname, or 32-character hexadecimal voice ID: $(tts.ai voice:gojo message). An unknown name or ID is refused and nothing plays. A plain first word is always part of the message.
$(set.voice name)Changes the default AI voice and selects AI Voices. Accepts a built-in name, favorite nickname, or favorite display name. In AI chat it requires moderator access; set custom command permissions carefully because it changes a channel-wide setting.

Older functions still work: $(tts.speak …) and $(tts.piper …) use Standard; $(tts.kokoro voice_id …) uses Standard with that ID; $(tts.clone voice …) and $(tts.fish voice …) use AI Voices with that voice.

Speech is subject to the channel’s filters and length limit. Standard costs 1 credit per 15 characters, rounded up, and keeps working below zero. AI Voices costs 1.5 credits per character, rounded up; when credits run out, the balance cannot be verified, or the voice fails while speaking, the line falls back to Standard without voice tags on every plan. Previews cost the normal speech rate; Standard previews work at zero credits, while AI voice previews need enough credits and never fall back.

Only available in Twitch channels. $(tts.status) summarizes connection status, playback state, and queue count; $(tts.connected) returns a boolean (returning false if the lookup fails); $(tts.queue.length) returns the queued item count, or -1 on lookup failure.

$(tts.skip) stops the active speech and advances the queue, $(tts.clear) stops playback and empties waiting items, and $(tts.refresh) reconnects playback—dropping interrupted speech while preserving waiting items. If an OBS browser source is closed, reopen it manually. These three control functions require moderator access in AI chat.

$(pet.talk text) speaks with your pet’s voice, while $(pet.ask prompt) asks your pet’s personality for a spoken reply. Both require a configured pet plus Premium or Pro, and work in authored Twitch commands or event actions (not in AI chat requests or scheduled timer bodies). Maximum length is 2,000 characters.

Triggers are sound or video alerts configured on the Triggers page—see Triggers.

FunctionWhat it doesExample
$(trigger.send name)Plays a trigger matching the exact name$(trigger.send airhorn)
$(trigger.send name true)Queues the trigger on the overlay instead of firing immediately$(trigger.send airhorn true)

Your OBS Browser Source from the Triggers page must be open for playback; if it’s disconnected, the function returns No trigger overlay clients connected. Missing, disabled, or media-less triggers return a short message like Trigger not found: airhorn. Moderator access is required in AI chat.

Manage the alert queue across your Overlay Studio scenes (moderator access required in AI chat). Make sure your Twitch account is linked to Overlay Studio—if the bot tells you to reconnect, re-link it from the dashboard.

FunctionWhat it does
$(overlay.skip)Cuts the current alert and starts the next one
$(overlay.pause)Holds upcoming alerts once the current one finishes
$(overlay.resume)Releases held alerts to play again
$(overlay.clear)Drops queued alerts while letting the current one finish

Append .twitch or .kick to target a single platform, such as $(overlay.skip.twitch).

FunctionWhat it doesExample
$(delay N)Pauses execution for N seconds (0 to 60; higher numbers return an error)$(delay 5)
$(timer seconds "message" $(action))Schedules a message and actions for 1 to 604800 seconds later while letting the command return immediately. See Execution, Errors & Limits$(timer 300 "Five minutes are up!")
$(break)Exits the current loop immediately$(break)
$(continue)Jumps straight to the next loop iteration$(continue)
$(chat.send message)Sends the first argument as a bot message; wrap multi-word text in quotes$(chat.send "Hello everyone!")
$(announce [color] message), $(announcement ...), or $(chat.announcement ...)Posts a Twitch announcement in blue, green, orange, purple, or primary (default) for 1–500 characters. If Twitch rejects it, returns the original text for normal command delivery instead of sending a duplicate fallback message. Moderator access in AI chat$(announce purple Five minutes left!)
$(shoutout target)Sends a native Twitch shoutout for one valid login; blank or invalid targets output nothing. Moderator access in AI chat$(shoutout streamer)
$(show.clip target)Best-effort playback of a cached clip from the target channel on your clip overlay; outputs nothing if the target is missing/invalid, has no clips, or the overlay isn’t connected. Moderator access in AI chat$(show.clip streamer)

The default !so reply relies on these functions. Because it uses &t (everything typed after !so), the input must be a single login—extra words invalidate the target. Switch to &p1 if you only want to read the first word and silently ignore anything after it. See Custom commands for editing !so and configuring its authoritative command access.

Twitch enforces two native shoutout rate limits: one accepted shoutout from your channel every 2 minutes, and one to the same target channel every 60 minutes. You must be live with at least one viewer, and the bot needs moderator status plus the required authorization. These Twitch API rules operate independently from your command’s editable cooldown and from its announcement or clip behavior. See Twitch’s Send a Shoutout API reference.

Part of the overlay category, both widget signal functions are free of plan caps on every tier. They fire a live signal and return empty text so you can place them right alongside normal chat copy, following the command’s own access level and cooldown. Signals fire from real Twitch chat commands, keywords, referenced commands, and Chat event messages—calling them from timers, channel-point rewards, roulette, AI requests, or dashboard/docs-assistant test boxes returns Error: widget_signal_context_required. Viewer text resembling $(...) is never evaluated.

FunctionDescriptionExample
$(widget.signal <name> [value…])Broadcasts to every widget in your channel’s published OBS overlays whose widget.json lists "signals" in uses. Signal names are lowercased and allow only lowercase letters, digits, and _ (up to 40 characters; dotted names like pet.feed return Error: invalid_widget_signal_name). Remaining arguments form the payload up to 500 characters (longer payloads return Error: widget_signal_too_long).$(widget.signal feed &p1)
$(widget.signal.to "<layer name>" <name> [value…])Targets only layers matching that name (case-insensitive, ignoring outer whitespace). If multiple layers share the name, all of them receive it.$(widget.signal.to "Pet" feed &p1)

Pass command input using standard placeholders—&p1, &p2, and &t for everything after the command (not $(1)). A reply like $(user) fed Mochi! $(widget.signal feed &p1) posts the chat line while triggering the widget. Each command run can emit at most 5 signals (shared across referenced commands), with a per-channel cap of 30 signals per 10 seconds; excess signals are silently dropped and counted. Duplicate deliveries of the same Twitch message never fire twice, and signals are live-only—they do not replay after an OBS reconnect.

FunctionExample useExample output
$(user)Welcome $(user)!Welcome ronchi!
$(random 20)You rolled: $(random 20)You rolled: 7
$(twitch.subs)We have $(twitch.subs) subscribers!We have 1542 subscribers!
$(count 1)Uses: $(count 1)Uses: 42
$(followage ronchi)$(user) has followed for $(followage ronchi)ronchi has followed for 2 months, 3 days, 5 hours
$(create.clip)Clip: $(create.clip)Clip: https://clips.twitch.tv/...
$(trigger.send airhorn)$(trigger.send airhorn)The trigger plays
$(chat.send "Hello everyone!")$(chat.send "Hello everyone!")Message posted

Docs assistant

Ask in your own words. Answers come from these docs, with links to the right page.

Try asking

Current page: AST Functions Reference

AI can make mistakes. Check the linked page.