Leveling

Setup

Activity XP and a level ladder for a Planeward community. Members see their level and the leaderboard in an app channel; staff edit the ladder and XP rules in the dashboard. Each level is a Planeward badge.

Run it in the local emulator
A local Planeward host, API and webhooks. No account or tunnel needed.
  1. Start Postgres with pnpm db:up and run pnpm --filter @repo/leveling db:migrate.
  2. Stop this server and run pnpm --filter @repo/leveling dev:emulator from the repo root. It starts the app with local PLANEWARD_* credentials and opens the emulator.
  3. Trigger community.message.created from the Activity panel, then watch XP, levels and badges change.
Environment
Read from this app’s .env locally, or the Worker’s secrets when deployed. Postgres is the HYPERDRIVE binding in wrangler.jsonc, not a variable. Values are never shown. Everything is set.
  • PLANEWARD_APP_IDSet
  • PLANEWARD_APP_SECRETSet
  • PLANEWARD_WEBHOOK_SECRETSet
  • PLANEWARD_BASE_URLSet
Register in Planeward
In Planeward: Apps › All apps › Create app. Built from this request’s host. Use your public HTTPS domain in production. Steps, browsers and webhooks: docs/going-live.md.
Scopes to request
The same scopes as planeward.json, which the emulator grants.
  • COMMUNITY_MEMBERS_READMembership webhooks (hide lapsed members), names and the dashboard member list
  • COMMUNITY_MESSAGES_READMessage and reaction webhooks for chat XP
  • COMMUNITY_MESSAGES_WRITEPost level-up messages in a chat channel
  • COURSES_READLesson and course completion webhooks
  • EVENTS_READEvent attendance webhooks
  • COMMUNITY_BADGES_WRITEOne level badge per member (level-1, level-2…)
  • COMMUNITY_NOTIFICATIONS_WRITETell a member when they reach a new level