Kapa ai doc qa

From CraftOS-dev/craftbot-agent-bundles · View interactive version

Kapa ai doc qa is an AI agent skill from the GitHub repository CraftOS-dev/craftbot-agent-bundles. Source: https://docs.kapa.ai/api/reference

How to use this skill

Skill file

<!--

Source: https://docs.kapa.ai/api/reference

Kapa.ai deflection rates: https://docs.kapa.ai/integrations/support-form-deflector/deflection-rates

-->

Kapa AI Doc Q&A — SKILL

Kapa.ai is the SOTA paid AI doc-Q&A service. Trained on a project's docs + ticket corpus, it answers technical questions, exposes deflection analytics, and surfaces content gaps (zero-result + low-confidence queries). Use this skill for doc-AI workflows, deflection metrics, and content-gap audits.

When to use

Trigger phrases: "Kapa deflection rate", "what's our top unanswered question", "ask Kapa", "Kapa content gap", "Kapa analytics".

Setup

# Kapa is API-first; no MCP server required. Direct curl works.
curl -sS https://api.kapa.ai/query/v1/projects \
  -H "X-API-Key: $KAPA_API_KEY" | jq '.[] | {id, name}'

Auth + env:

Workspace prerequisites:

Common recipes

Recipe 1: Ask Kapa a question (the `query` endpoint)

curl -sS -X POST "https://api.kapa.ai/query/v1/projects/$KAPA_PROJECT_ID/chat" \
  -H "X-API-Key: $KAPA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query":"How do I configure SSO with Okta?",
    "user_session_id":"u_abc123",
    "include_sources":true
  }' | jq '.answer, .confidence, .sources[].url'

confidence returned 0-1. Gate human escalation on confidence < 0.7 per role.md guidance.

Recipe 2: Stream chat response (for in-product widget)

curl -sS -N -X POST "https://api.kapa.ai/query/v1/projects/$KAPA_PROJECT_ID/chat/stream" \
  -H "X-API-Key: $KAPA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"How do I rotate the API key?","stream":true}'

Returns Server-Sent Events. For terminal use, prefer Recipe 1.

Recipe 3: Pull deflection metrics for last 30 days

curl -sS "https://api.kapa.ai/analytics/v1/projects/$KAPA_PROJECT_ID/deflection?period=30d" \
  -H "X-API-Key: $KAPA_API_KEY" | jq '{
    total_queries: .total_queries,
    deflected: .deflected_count,
    rate: .deflection_rate,
    escalated_to_human: .escalation_count
  }'

Deflection rate is deflected / total_queries. Industry benchmark: 30-50% on a mature docs corpus.

Recipe 4: Top zero-result / unanswered queries

curl -sS "https://api.kapa.ai/analytics/v1/projects/$KAPA_PROJECT_ID/queries/unanswered?period=30d&limit=20" \
  -H "X-API-Key: $KAPA_API_KEY" | jq '.queries[] | {query, count, last_asked_at}'

Use as the seed list for new KB articles or FAQ entries. Filter for count >= 5 as the cluster threshold.

Recipe 5: Low-confidence answers (content needs improving)

curl -sS "https://api.kapa.ai/analytics/v1/projects/$KAPA_PROJECT_ID/queries/low-confidence?period=30d&threshold=0.6&limit=20" \
  -H "X-API-Key: $KAPA_API_KEY" | jq '.queries[] | {query, confidence, top_source}'

Queries where Kapa answered but the agent was unsure. These mean an existing doc is incomplete / outdated / poorly indexed.

Recipe 6: Sync feedback (thumbs up / down)

curl -sS -X POST "https://api.kapa.ai/feedback/v1/projects/$KAPA_PROJECT_ID/feedback" \
  -H "X-API-Key: $KAPA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"thread_id":"th_abc","rating":"thumbs_up","comment":"Resolved my question."}'

Drives Kapa's model retraining loop. Pipe widget feedback through this for continuous improvement.

Recipe 7: List configured knowledge sources

curl -sS "https://api.kapa.ai/management/v1/projects/$KAPA_PROJECT_ID/sources" \
  -H "X-API-Key: $KAPA_API_KEY" | jq '.[] | {id, type, url, last_indexed_at}'

Check last_indexed_at weekly — if a source hasn't re-indexed in >14d, Kapa is serving stale answers.

Recipe 8: Trigger re-index of a source

curl -sS -X POST "https://api.kapa.ai/management/v1/projects/$KAPA_PROJECT_ID/sources/$SOURCE_ID/reindex" \
  -H "X-API-Key: $KAPA_API_KEY"

Required after major docs releases. Returns a job ID; poll /jobs/$id for completion.

Recipe 9: Get usage by source (which docs Kapa cites most)

curl -sS "https://api.kapa.ai/analytics/v1/projects/$KAPA_PROJECT_ID/sources/usage?period=30d" \
  -H "X-API-Key: $KAPA_API_KEY" | jq '.[] | {url, citation_count, helpfulness_rate}'

High-citation + high-helpfulness = winning content. Low-helpfulness + high citation = doc is needed but unhelpful — rewrite candidate.

Recipe 10: Webhook on new question (real-time analytics)

curl -sS -X POST "https://api.kapa.ai/management/v1/projects/$KAPA_PROJECT_ID/webhooks" \
  -H "X-API-Key: $KAPA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url":"https://your-agent.example.com/webhooks/kapa",
    "events":["query.answered","query.unanswered","feedback.submitted"]
  }'

Wire low-confidence answers to immediately log a Notion task for the technical-writer agent.

Recipe 11: Search the knowledge base directly (semantic search, no LLM)

curl -sS -X POST "https://api.kapa.ai/search/v1/projects/$KAPA_PROJECT_ID/search" \
  -H "X-API-Key: $KAPA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"SSO Okta setup","limit":10}' | jq '.results[] | {title, url, score}'

Faster + cheaper than /chat if you only need top-K relevant docs (e.g., for ticket-deflection suggestion at compose-time).

Recipe 12: Free fallback (Markprompt) when Kapa not available

# Markprompt OSS — drop-in alternative
curl -sS https://api.markprompt.com/v1/chat/completions \
  -H "X-API-Key: $MARKPROMPT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"messages":[{"role":"user","content":"How do I rotate the API key?"}],"projectKey":"$PROJECT_KEY","stream":false}'

Markprompt is OSS / freemium; covers the basic /chat + sources surface. Less polished analytics but usable when Kapa budget is unavailable.

Examples

Example 1: Weekly content-gap report → Notion drafts

Goal: Auto-draft KB articles for top 5 unanswered queries each week.

Steps:

  1. GET /analytics/v1/projects/$id/queries/unanswered?period=7d&limit=10.
  2. Filter for count >= 5.
  3. For each query: Claude drafts a KB article using the article template from role.md.
  4. notion-mcp create_page in the "KB drafts" DB with status="needs review".
  5. Email technical-writer agent: "5 new drafts await review."

Result: KB drift detected and addressed weekly without manual triage.

Example 2: Deflection-cascade — Kapa first, human second

Goal: Pre-screen Help Center submit-form questions; let Kapa answer; only escalate the ones Kapa is unsure on.

Steps:

  1. Customer submits a question in the in-product help widget.
  2. Agent calls Recipe 1; reads answer + confidence.
  3. If confidence >= 0.7: surface the answer to the customer with a "Was this helpful?" follow-up.
  4. If confidence < 0.7 OR customer says "Talk to a human": create Zendesk / Intercom ticket with the original question + Kapa's draft as an internal note (so the agent doesn't start from scratch).

Result: 40%+ deflection; agents inherit context on the ones that escalate.

Edge cases / gotchas

Sources

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.