Skip to content

Fix /login: restore /api/bots/ingest + link endpoints for standalone bots - #8

Merged
nermalcat69 merged 2 commits into
mainfrom
bot-compat-endpoints
Sep 6, 2026
Merged

nermalcat69 merged 2 commits into
mainfrom
bot-compat-endpoints

Conversation

@KrishnaSSH

Copy link
Copy Markdown
Member

Problem

/login in the Discord bot (and Slack/Telegram) defers "thinking…" and never replies. The 0013 dashboard-connect rewrite deleted /api/bots/ingest and /api/bots/link/* — every endpoint the standalone bot repos (discord/telegram/slack.grayoffice) call. Deployed grayoffice.app returns 404 for all of them.

Fix (additive — no behaviour change to bots.ts / bot-router.ts)

  • migrations/0014_bot_link_compat.sql — bot_link_codes + bot_links (the latter now carries org_id).
  • workers/bot-compat.ts — /api/bots/ingest + /api/bots/link/{start,status,revoke}, mounted on /api/bots before the /:platform/:orgId webhook router (different segment counts, no collision).
    • /ingest resolves the linked user + org from bot_links and runs the same handleInbound → runFinanceAgentText path the webhooks use (real agent + tools when linked; Workers-AI fallback when not).
    • idempotency via the existing bot_processed_events ledger.
  • app/routes/link.tsx — the enter-your-code page at /link (signed-in; writes bot_links for the user's first org).
  • route + mount wiring in app/routes.ts, workers/app.ts.

To go live

wrangler d1 migrations apply grayoffice-db --remote
npm run deploy

The bot repos need GRAYOFFICE_URL pointed at the deployment and BOT_INGEST_TOKEN matching.

Note

This keeps the standalone-bot model working alongside the dashboard-connect one. Longer term they should converge (see #7).

🤖 Generated with Claude Code

The 0013 dashboard-connect rewrite removed the endpoints the discord/
telegram/slack.grayoffice bot repos depend on, so /login just hangs.

- migrations/0014: bot_link_codes + bot_links (now carrying org_id)
- workers/bot-compat.ts: /api/bots/ingest + /api/bots/link/{start,status,revoke},
  mounted before the /:platform/:orgId webhook router
- app/routes/link.tsx: enter-the-code page at /link
- ingest resolves the linked user+org and runs the same handleInbound /
  runFinanceAgentText path as the webhooks; idempotency via bot_processed_events

Additive — no change to bots.ts / bot-router.ts behaviour.
@nermalcat69
nermalcat69 merged commit 9cfe24b into main Sep 6, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants