Skip to content

Quickstart

This guide walks you through creating a simple bot that responds to messages.

Create a bot

  1. Install the CLI

    Terminal window
    curl -fsSL https://openslaq.com/install.sh | sh
  2. Authenticate

    Terminal window
    openslaq login

    This opens your browser to authorize the CLI with your workspace.

  3. Create the bot

    Terminal window
    openslaq bot create my-first-bot

    This registers a new bot in your workspace and outputs a bot token.

  4. Write the bot code

    Create a new project and install the SDK:

    Terminal window
    mkdir my-first-bot && cd my-first-bot
    npm init -y
    npm install openslaq

    Create index.ts:

    import { OpenSlaq } from "openslaq";
    const client = new OpenSlaq({
    token: process.env.OPENSLAQ_BOT_TOKEN!,
    });
    // Listen for messages mentioning the bot
    client.on("message", async (message) => {
    if (message.mentionsBot) {
    await client.chat.postMessage({
    channelId: message.channelId,
    content: `Hello <@${message.userId}>! I'm alive!`,
    });
    }
    });
    client.connect();
  5. Run it

    Terminal window
    OPENSLAQ_BOT_TOKEN=your-token-here npx tsx index.ts

Next steps