The Opponent

A literal barrel of sunshine. *Contents may vary.

Controlling Twitch Channel Point Rewards Using Kruiz-Control


Kruiz-Control is a popular browser source for responding to channel point redemptions without using the API, but it is capable of controlling all aspects of rewards themselves that are exposed in the API. Channel points rewards on Twitch can be created via the API using developer-defined apps, but in order for those rewards to be manipulated automatically, they must have been created by those apps.

The easiest way to create channel point rewards that will be modified dynamically is to use curl, as recommended by the Twitch developer documentation. I used the Windows Subsystem For Linux running Debian to get access to curl. Get an OAuth token with the implicit grant flow method that includes the channel:manage:redemptions scope (add &scope=channel%3Amanage%3Aredemptions to your URL), and check the access_token parameter in the localhost URL that you're led to for the Bearer authorization.

With the access token, use curl to make a new channel point reward. Get the id in the JSON response.

After creating the reward, all further updates can be made using Kruiz-Control script commands by copying the app's client ID into its script. One of the most common use cases is to temporarily disable a reward at the beginning of the stream that normally has a cooldown, to ensure a certain amount of stream time can elapse before it is redeemed. For the required header information, I recommend setting global variables at init.

OnInit
Variable Global Set TwitchAPIAuth "Bearer <Your access token>"
Variable Global Set TwitchAPIClient "<Your app's client ID>"
Variable Global Set TwitchAPIChannelPointsUrl "https://api.twitch.tv/helix/channel_points/custom_rewards?broadcaster_id=<Your broadcaster ID, found in API responses>&id=<Your reward's ID from the API response>"

To temporarily disallow redeeming the channel point reward, set the is_paused property to true or false. Alternatively, set the is_enabled property to true and false to temporarily hide the reward entirely (note that this will need to be done if the "Skip Reward Requests Queue" option is enabled for the reward as this disables pausing redemptions). Add a Delay statement with the amount of seconds (30 minutes in this example) that the stream must be live before it can be redeemed. You may also wish to add a Chat Send statement to inform viewers that the reward is now available.

OnOBSStreamStarted
Variable Global Load TwitchAPIAuth
Variable Global Load TwitchAPIClient
Variable Global Load TwitchAPIChannelPointsUrl
API Method TwitchAPI PATCH
API Url TwitchAPI {TwitchAPIChannelPointsUrl}
API Header TwitchAPI "Authorization" {TwitchAPIAuth}
API Header TwitchAPI "Client-Id" {TwitchAPIClient} 
API Data TwitchAPI "is_paused" "true"
API Send TwitchAPI
Delay 1800
# Optional Chat Send statement.
Chat Send "The channel point reward is now open!"
API Data TwitchAPI "is_paused" "false"
API Send TwitchAPI

# ...

# Pause the reward after the stream ends.
OnOBSStreamStopped
Variable Global Load TwitchAPIAuth
Variable Global Load TwitchAPIClient
Variable Global Load TwitchAPIChannelPointsUrl
API Method TwitchAPI PATCH
API Url TwitchAPI {TwitchAPIChannelPointsUrl}
API Header TwitchAPI "Authorization" {TwitchAPIAuth}
API Header TwitchAPI "Client-Id" {TwitchAPIClient} 
API Data TwitchAPI "is_paused" "true"
API Send TwitchAPI