Tutorial · Free · 5 minutes

Build a TikTok LIVE chat bot

Read every chat, gift, and join event from any TikTok LIVE stream and react to commands in your own app. Run in Node.js or Python with under 60 lines of code.

1

Install the SDK

One package. No build step. Works in any Node 18+ or Python 3.9+ environment.

npm install @tiktool/live
2

Set your credentials

You need one thing:

export TIKTOOL_API_KEY="tk_yourkey"
export TIKTOK_USERNAME="target_streamer"
3

Write the bot

Listens for chat, gifts, joins, likes. Reacts to !hello and !ping commands with your own action: an overlay, a sound, a webhook.

// bot.mjs
import { TikTokLive } from '@tiktool/live'

const USERNAME = process.env.TIKTOK_USERNAME
const API_KEY  = process.env.TIKTOOL_API_KEY

// Your reaction to a command: trigger an overlay, play a sound, call a webhook.
function onCommand(name, user) {
  console.log(`command ${name} from @${user}`)
}

const client = new TikTokLive({ uniqueId: USERNAME, apiKey: API_KEY })
client.on('connected', e => console.log(`connected to room ${e.roomId}`))
client.on('chat', e => {
  console.log(`@${e.user.uniqueId}: ${e.comment}`)
  if (e.comment.toLowerCase() === '!hello') onCommand('hello', e.user.uniqueId)
  if (e.comment.toLowerCase() === '!ping')  onCommand('ping', e.user.uniqueId)
})
client.on('gift', e => console.log(`gift: ${e.user.uniqueId} → ${e.giftName} (${e.diamondCount}💎)`))
client.connect()
4

Run it

The bot stays connected until you stop it. Reconnect logic is built into the SDK.

node bot.mjs

Type !hello or !ping from any TikTok account into the streamer's chat and your bot replies as your account.

Limitations to plan around

Everything below is what TikTok enforces on your account/IP - not something tik.tools can lift. Build your bot logic with these in mind.

~100k

events per stream per minute

Big creators (1M+ viewers) push tens of thousands of events per minute. Your bot needs to process them lazily - don't block the event loop on every chat. Drop or queue heavy work.

stream end

session ends with the LIVE

When the streamer ends their LIVE, the WebSocket closes. The SDK fires disconnected. Reconnect after the streamer goes live again - poll tik.tools/api/live/check-live or use webhooks.

not affiliated

not endorsed by TikTok

This is an unofficial integration. Use a dedicated TikTok account for the bot, don't mix it with your main, and don't impersonate creators. TikTok may suspend the account if the bot looks like spam.