Skip to content

Add custom Kapa handoff ticket flow for docs chat - #368

Draft
dannyneira wants to merge 3 commits into
mainfrom
danny/kapa-handoff-preview
Draft

Add custom Kapa handoff ticket flow for docs chat#368
dannyneira wants to merge 3 commits into
mainfrom
danny/kapa-handoff-preview

Conversation

@dannyneira

Copy link
Copy Markdown
Member

Summary

  • add an always-on Create ticket action to the custom Kapa chat footer UI
  • add a structured handoff form (email + optional note) styled to match current chat controls
  • submit full conversation context (Q/A transcript, sources, page URL, thread ID, timestamp) to a new backend endpoint
  • add /api/kapa-handoff with preview mode by default and optional webhook forwarding via KAPA_HANDOFF_WEBHOOK_URL

Why

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)
  • verify handoff flow in preview/deploy:
    • open Ask chat
    • click Create ticket
    • submit with email and optional note
    • confirm success state and payload handling

Artifacts

Co-Authored-By: Oz oz-agent@warp.dev

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>
@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Error Error Jul 23, 2026 11:41pm

Request Review

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>
@dannyneira
dannyneira marked this pull request as ready for review July 23, 2026 23:35
@oz-for-oss

oz-for-oss Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

@dannyneira

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 /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@dannyneira
dannyneira marked this pull request as draft July 23, 2026 23:38

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/pages/kapa-handoff.ts
return `${value.slice(0, maxLength)}…`;
}

export const POST: APIRoute = async ({ request }) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] [SECURITY] This public endpoint accepts and forwards/logs arbitrary transcript payloads with no abuse control or field-size limits; add rate limiting/CAPTCHA or equivalent gating plus server-side caps before enabling webhook delivery.

Comment thread src/pages/kapa-handoff.ts
});
}

const replyToEmail = payload.replyToEmail?.trim() ?? '';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] 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.

Comment thread src/pages/kapa-handoff.ts
});
}

console.info(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] [SECURITY] Preview mode writes the user's email, note, page URL, and transcript to server logs; log metadata only or gate preview logging so support conversations and contact info are not retained in logs by default.

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>
@dannyneira
dannyneira marked this pull request as ready for review July 23, 2026 23:47
@dannyneira
dannyneira marked this pull request as draft July 23, 2026 23:47
@oz-for-oss

oz-for-oss Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

@dannyneira

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 /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/pages/kapa-handoff.ts
return `${value.slice(0, maxLength)}…`;
}

export const POST: APIRoute = async ({ request }) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] [SECURITY] This anonymous endpoint forwards every valid submission to the configured webhook with no bot protection, rate limiting, or abuse control. Add a CAPTCHA/rate-limit guard before accepting submissions, otherwise anyone can spam support or force webhook traffic.

Comment thread src/pages/kapa-handoff.ts
Comment on lines +88 to +90
console.info(
'[kapa-handoff-preview] Received handoff request:\n',
truncate(ticketBody, 6000)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] [SECURITY] Preview mode logs the reply-to email, note, page URL, and transcript. If 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant