Bot API guide
Quickstart
Six steps from nothing to a working bot. The snippets use the same handshake as the sample bot in the repository.
1. Create an application
Opening an application in the portal creates a bot user behind it. The application name becomes the bot’s display name.
My applications2. Mint a token and keep it
Mint a token on the application page. It is shown once; if you lose it you have to rotate.
TALKITH_BOT_TOKEN=nsb_... TALKITH_API_ORIGIN=https://api.talkith.com TALKITH_GATEWAY_ORIGIN=wss://api.talkith.com
3. Connect to the gateway
The socket opens with HELLO, you authenticate with IDENTIFY, and heartbeat on the interval HELLO gave you.
const socket = new WebSocket( `${process.env.TALKITH_GATEWAY_ORIGIN}/gateway/bot` ); socket.addEventListener('message', (event) => { const frame = JSON.parse(event.data); if (frame.op === 'HELLO') { // HELLO kalp atışı aralığını taşır; IDENTIFY ile kimliği bildir. socket.send(JSON.stringify({ op: 'IDENTIFY', d: { token: process.env.TALKITH_BOT_TOKEN, intents: ['APPLICATION_COMMANDS', 'SERVER_MESSAGES'], }, })); setInterval( () => socket.send(JSON.stringify({ op: 'HEARTBEAT' })), frame.d.heartbeatInterval ); } });4. Register your commands
Slash commands are registered by the bot, not in the portal. This endpoint replaces the whole list.
await fetch(`${API}/api/bot/v1/commands`, { method: 'PUT', headers: { Authorization: `Bot ${token}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ commands: [ { name: 'ping', description: 'Botun ayakta olduğunu doğrular' }, ], }), });5. Answer the command
When a user runs the command an APPLICATION_COMMAND arrives; answer the interaction promptly.
if (frame.op === 'DISPATCH' && frame.t === 'APPLICATION_COMMAND') { const interactionId = frame.d.interactionId; await fetch( `${API}/api/bot/v1/interactions/${interactionId}/response`, { method: 'POST', headers: { Authorization: `Bot ${token}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ content: 'pong' }), } ); }6. Take the rest from the reference
Messages, reactions, attachments, voice and WHIP are all in the reference, with parameters and bodies.
Open the reference