This is the prescribed deployment method for the reference implementation: Vercel (serverless).
From the repo root (this folder):
npm install
vercelWhen prompted, set the root directory to this folder if you’re in a parent monorepo. Follow the prompts to link a new or existing Vercel project.
Your webhook URL will be:
https://<your-project>.vercel.app/api/dice-game
Use this as WEBHOOK_URL in .env when running npm run setup.
The dice game uses Vercel KV for balances and pending bets.
- In Vercel Dashboard → your project → Storage
- Create a KV database
- Connect it to the project (Vercel adds the required env vars automatically)
Run from this folder (with .env containing CRUSTOCEAN_USER, CRUSTOCEAN_PASS, WEBHOOK_URL, CRUSTOCEAN_AGENCY_ID):
npm run env:vercelThis generates the global hook key from Crustocean and pushes CRUSTOCEAN_API_URL and CRUSTOCEAN_HOOK_KEY to your Vercel project. The hook key is required for /dicebet @username (resolving usernames).
| Variable | Description | Set by |
|---|---|---|
CRUSTOCEAN_API_URL |
https://api.crustocean.chat |
npm run env:vercel |
CRUSTOCEAN_HOOK_KEY |
Global hook key (one per webhook) | npm run env:vercel |
Do not commit .env or store secrets in the repo. Use Vercel’s env UI or CLI for production.
After deploy, register your slash commands so Crustocean knows where to send webhook requests:
- Copy
.env.exampleto.envin this folder. - Set
CRUSTOCEAN_USER,CRUSTOCEAN_PASS,CRUSTOCEAN_AGENCY_ID, andWEBHOOK_URL(your Vercel URL, e.g.https://<project>.vercel.app/api/dice-game). - Run:
npm run setup
npm run env:vercelThis creates/updates the custom commands in the given agency. Users in that agency can then use /custom to list commands and (if the hook is installable) others can run /hook install dicebot in their own agencies (after you’ve published from a public agency).
vercel link
vercel env pull
npm run devUse ngrok or similar to expose http://localhost:3000/api/dice-game if you need to test against Crustocean from your machine.
- Deploy →
vercel - Add KV storage and connect to project
- Set
.envlocally withCRUSTOCEAN_USER,CRUSTOCEAN_PASS,CRUSTOCEAN_AGENCY_ID,WEBHOOK_URL - Run
npm run setupto register commands - Run
npm run env:vercelto pushCRUSTOCEAN_HOOK_KEYto Vercel - Redeploy:
vercel --prod