Chat Rate Limits

Chat send is rate-limited to prevent spam and protect the channel’s bot account from platform bans.

Limits

ScopeLimit
Per widget5 messages per 60 seconds
Message length500 characters max

What Happens When Rate Limited

Messages that exceed the limit are dropped. chat.send() returns false when the message wasn’t delivered.
const sent = await SBCanvas.chat.send('Hello!');
if (!sent) {
  console.log('Rate limited, message not sent');
}

Safe Sending Pattern

Space out messages to stay within limits:
let lastSend = 0;
const MIN_INTERVAL = 12000; // 12 seconds = max 5 per minute

async function safeSend(message) {
  const now = Date.now();
  if (now - lastSend < MIN_INTERVAL) return false;
  lastSend = now;
  return await SBCanvas.chat.send(message);
}

Queued Sending

For widgets that generate many messages, queue and space them:
SBCanvas.service.register('chat-queue', {
  init() {
    this.queue = [];
    this.interval = SBCanvas.setInterval(() => {
      if (this.queue.length > 0) {
        const msg = this.queue.shift();
        SBCanvas.chat.send(msg);
      }
    }, 12000);
  },

  dispose() {
    SBCanvas.clearTimer(this.interval);
  },

  send(message) {
    if (this.queue.length < 10) {
      this.queue.push(message);
    }
  }
});

Best Practices

  • Don’t send a message for every single follow or sub — batch them or use a threshold
  • Use SBCanvas.preview.isActive to skip sends during testing
  • Keep messages short and relevant to your stream
  • Consider your audience — spammy bot messages are annoying