Squiso is a free, powerful automation tool that lets you customize your Twitch stream using simple scripts.

How to Create a Twitch Announcement Chat Message and Play Audio When a Twitch Ad Break Starts

This script example listens to when Twitch ad breaks starts and then sends an chat announcement and plays an audio file.

Script Example

import com.squiso.*; import com.squiso.exception.*; import com.squiso.scripting.*; import com.squiso.scripting.data.*; import com.squiso.keyboard.*; import com.squiso.twitch.*; import com.squiso.datatypes.*; import com.squiso.utils.*; // Important - Please do not change the row below - otherwise you will get a compilation error! public class Script_Example extends SquisoScript { @Override public void onTwitchAd(OnTwitchAdData data, API api) throws SquisoException { // Compose an announcement message SquisoString message = new SquisoString("⚠️ " + data.getDuration() + " SECONDS ADS STARTED ⚠️ THANK YOU FOR SUPPORTING THE CHANNEL! ⚠️"); // Send the announcement message SquisoString color = new SquisoString("green"); api.sendTwitchChatAnnouncement(message, "green"); // Play some audio String audioFile = "sample.mp3"; api.playAudio(audioFile); } }