Set up the bot

Create a Discord application and deploy ctrlaltbot to your Cloudflare account.

Each server runs its own copy of ctrlaltbot, in your own Cloudflare account, pointed at your own docs site.

Set up with the Deploy button #

  1. Create the Discord application

    In the Discord Developer Portal , create an application. Then note three values:

    • Application ID and Public Key, from General Information.
    • Bot token, from Bot. Select Reset Token to reveal it.

    Keep the token secret. Anyone with it can act as your bot.

  2. Deploy to Cloudflare

    Open Deploy to Cloudflare and fill in:

    FieldValue
    CAD_BASE_URLYour docs site's address, for example https://docs.example.com
    DISCORD_CLIENT_IDThe Application ID
    DISCORD_PUBLIC_KEYThe Public Key
    DISCORD_TOKENThe bot token

    Cloudflare creates a repository for your bot in your GitHub or GitLab account, creates the storage the bot needs, and deploys it. When it finishes, copy the Worker's URL, such as https://ctrlaltbot.your-name.workers.dev.

  3. Connect Discord to the bot

    Back in the Developer Portal, open General Information and paste the Worker URL into Interactions Endpoint URL. Discord checks the endpoint when you save.

    Saving also prompts the bot to register its slash commands, so /ask and /docs appear within a minute or two.

  4. Invite the bot to your server

    Open this link with your Application ID in place of YOUR_APPLICATION_ID, then choose your server:

    text
    https://discord.com/oauth2/authorize?client_id=YOUR_APPLICATION_ID&scope=bot+applications.commands
  5. Try it

    In your server, run /ask with a question your docs answer.

From now on, updates install themselves. See Updates and upgrading .

Set up without the Deploy button #

You can deploy from your own machine or CI instead. You need Node.js 20 or later.

bash
git clone https://github.com/ctrl-alt-doc/ctrlaltbot.git
cp -r ctrlaltbot/template my-bot
cd my-bot
npm install

Edit the vars in wrangler.jsonc, then sign in to Cloudflare, add the two secrets, and deploy:

bash
npx wrangler login
npx wrangler secret put DISCORD_PUBLIC_KEY
npx wrangler secret put DISCORD_TOKEN
npx wrangler deploy

Wrangler creates the bot's storage on the first deploy. Then continue from step 3 above.

To get updates automatically, push the folder to a GitHub repository and connect it to the Worker in the Cloudflare dashboard, under Workers & Pages → your Worker → Settings → Builds → Connect. Otherwise, update by hand. See Updates and upgrading .

Test on one server first #

While trying things out, set DISCORD_GUILD_ID to your test server's ID in wrangler.jsonc vars. The bot then registers its commands to that server only, where changes appear instantly. Remove it when you're ready for the commands to be available everywhere the bot is invited.

For all settings, see the Configuration reference .