Add front-to-admin-chat: Front context → admin chat with prefilled query#2
Open
jorrit-stack wants to merge 2 commits into
Open
Add front-to-admin-chat: Front context → admin chat with prefilled query#2jorrit-stack wants to merge 2 commits into
jorrit-stack wants to merge 2 commits into
Conversation
…led query
New Raycast script for chaining Front context into the bolt admin chat
(currently hosted at hackday-admin-chat.bolt-cnr.pages.dev, will move to
bolt.new/admin). The admin chat accepts a `?q=` URL param that prompts
on load, so no DOM injection is needed.
Flow:
1. Resolve cnv_id from arg or active Front browser tab
2. Front API: fetch conversation + first inbound message → customer email,
subject, body (HTML stripped, Front template placeholders like {text}
and {{customer.name}} removed)
3. stackblitz.com/admin lookup (same two-stage AppleScript pattern as
customer-360 + bolt-admin.sh): resolve UserID, recent project slugs,
and org memberships from the profile page
4. Regex-extract any ProjectIDs mentioned in the message body
(sb1-*, github-*, webcontainer-*, bolt.new/~/* URLs)
5. Build a natural-language question with all context
6. Open the admin chat with the question pre-filled via ?q=
Defaults:
- BOLT_ADMIN_CHAT_URL env var (default hackday URL) — easy switch when
bolt.new/admin lands
- --ask "..." flag to override the trailing question, keeping the
customer context
- --print to dump the URL without opening
- Message body capped at 3000 chars to keep URL length safe
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The stackblitz admin search-results table sometimes renders after document.readyState becomes 'complete', so the first profile-link find returns empty. Add up to 4 retries on the same active tab with an 800ms gap between attempts before giving up. Avoids re-navigating — just re-executes the find JS — so it's cheap. In practice: failed twice in a row on the same email under stale browser state, then succeeded on the second retry. Eliminates the "lookup failed → chat opens without UserID" failure mode the user hit. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New Raycast script
front-to-admin-chat/that takes a Front conversation, pulls customer context (email, UserID via stackblitz admin, recent project slugs, orgs), and opens the bolt admin chat with a pre-filled question via the?q=URL param.Discovered the admin chat accepts a query-param prompt that auto-submits on load — so this script just builds a URL, no DOM injection or React-input juggling needed. Will keep working when the chat moves from
hackday-admin-chat.bolt-cnr.pages.devtobolt.new/adminsince the URL pattern is the same; flipBOLT_ADMIN_CHAT_URLin.envwhen it lands.Flow
cnv_id— from positional arg, Front URL arg, or the active Chromium tab (AppleScript readsURL of active tab of front window).{text},{{customer.name}}) removed.customer-360/andbolt-admin.sh: open search → find profile link → navigate tab → parse profile innerText for UserID, recent project slugs (last 10), org memberships.sb1-*,github-*,webcontainer-*,bolt.new/~/*.{BOLT_ADMIN_CHAT_URL}/admin/chat?q={encoded}.Config
Reuses
cx-briefing/.env:FRONT_API_KEY(required)BOLT_ADMIN_CHAT_URL(optional, defaulthttps://hackday-admin-chat.bolt-cnr.pages.dev)Flags
--ask "<custom question>"— override the trailing ask, keep the customer context--print— dump the prepared question and URL, don't open the browserSmoke test (real conversation)
Known limitation
The two-stage browser automation has a small race window — if the search-results page hasn't finished rendering when the AppleScript reads it, the profile-link finder returns empty. Manifested once during testing; immediately succeeded on retry. A bounded retry can land in a follow-up; for now it's "rerun if it whiffs."
Test plan
node front-to-admin-chat/index.js <cnv_id> --print— exits cleanly, URL is < 2000 chars--ask "<custom>"— replaces only the trailing question--print) opens the admin chat with the prompt visible and the chat auto-submits🤖 Generated with Claude Code