Chat Send

Send messages from your widget to the stream chat. Messages are sent through the channel’s connected bot account.

SBCanvas.chat.send

const success = await SBCanvas.chat.send('Thanks for the follow!');
ParamTypeDescription
messagestringMessage text, max 500 characters
Returns Promise<boolean>.

Example: Thank Followers

SBCanvas.activities.on('follow', async (activity) => {
  await SBCanvas.chat.send(`Welcome ${activity.username}!`);
});

Example: Announce Milestones

SBCanvas.ready(() => {
  let subCount = 0;

  SBCanvas.activities.on('subscribe', async () => {
    subCount++;
    if (subCount % 10 === 0) {
      await SBCanvas.chat.send(`We just hit ${subCount} subs this stream!`);
      SBCanvas.confetti({ count: 100 });
    }
  });
});

Rate Limits

ConstraintLimit
Messages per minute5
Max message length500 characters
Messages exceeding the rate limit are silently dropped. Build in your own spacing:
let lastSend = 0;

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

Skip in Preview

Don’t send chat messages during testing:
SBCanvas.activities.on('follow', async (activity) => {
  showFollowAlert(activity);

  if (!SBCanvas.preview.isActive) {
    await SBCanvas.chat.send(`Welcome ${activity.username}!`);
  }
});