Add custom Kapa handoff ticket flow for docs chat - #368
Conversation
Adds an always-on Create ticket action in the Kapa chat UI, includes transcript context in submissions, and provides a preview/webhook backend endpoint for handoff testing. Co-Authored-By: Oz <oz-agent@warp.dev>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Set the handoff endpoint to non-prerendered so static/SSR build inputs resolve correctly in CI and Vercel. Co-Authored-By: Oz <oz-agent@warp.dev>
|
I'm starting a first review of this pull request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR adds a Kapa chat "Create ticket" handoff form and a new /api/kapa-handoff endpoint that either forwards transcripts to a configured webhook or logs preview submissions.
Concerns
- The new public POST route can be invoked directly and forwards or logs user-controlled transcript content without abuse controls or field-size limits.
- The route assumes parsed JSON is a non-null object with string fields, so valid but malformed payloads can still throw 500s.
- Preview mode logs reply email, note, page URL, and transcript into server logs by default.
Security
- Add abuse protection and server-side size limits before forwarding support-ticket payloads.
- Avoid retaining user conversation content or email addresses in preview logs by default.
Spec alignment
No approved or repository spec context was provided, so no spec-drift findings were evaluated.
Verdict
Found: 0 critical, 3 important, 0 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
| return `${value.slice(0, maxLength)}…`; | ||
| } | ||
|
|
||
| export const POST: APIRoute = async ({ request }) => { |
There was a problem hiding this comment.
| }); | ||
| } | ||
|
|
||
| const replyToEmail = payload.replyToEmail?.trim() ?? ''; |
There was a problem hiding this comment.
request.json() can return null or non-object values, so this property read can throw a 500; validate that payload is a non-null object and coerce/check field types before using them.
| }); | ||
| } | ||
|
|
||
| console.info( |
There was a problem hiding this comment.
Move the custom handoff POST route to /kapa-handoff and remove the stale /api/kapa-handoff file to avoid CI/Vercel SSR rollup conflicts with the /api docs page. Co-Authored-By: Oz <oz-agent@warp.dev>
|
I'm starting a first review of this pull request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR adds a custom Kapa handoff form to the docs chat UI and a new Astro POST endpoint that either forwards submissions to a configured webhook or records preview submissions server-side.
Concerns
- The new public handoff endpoint accepts anonymous submissions and forwards them to the webhook without visible bot protection, rate limiting, or other abuse controls.
- Preview mode logs user email, note, page URL, and transcript content to server logs when the webhook is unset.
Security
- The endpoint should add anti-abuse controls before forwarding ticket payloads.
- Preview mode should avoid logging sensitive user-provided conversation data.
Verdict
Found: 0 critical, 2 important, 0 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
| return `${value.slice(0, maxLength)}…`; | ||
| } | ||
|
|
||
| export const POST: APIRoute = async ({ request }) => { |
There was a problem hiding this comment.
| console.info( | ||
| '[kapa-handoff-preview] Received handoff request:\n', | ||
| truncate(ticketBody, 6000) |
There was a problem hiding this comment.
KAPA_HANDOFF_WEBHOOK_URL is missing in production, user PII and conversation content will be persisted in platform logs; return preview metadata without logging ticketBody, or redact the sensitive fields first.
Summary
Create ticketaction to the custom Kapa chat footer UI/api/kapa-handoffwith preview mode by default and optional webhook forwarding viaKAPA_HANDOFF_WEBHOOK_URLWhy
Search behavior is production-build-dependent, so this change needs CI/preview validation in a draft PR instead of relying on local dev mode.
Testing
npm run typecheck(passes)npm run build(passes)Artifacts
Co-Authored-By: Oz oz-agent@warp.dev