Skip to main content

bff-qna-service

RAG-based Q&A service for the dashboard. Uses Vectorize for document embeddings and Workers AI for answer generation. Includes a cron job that re-indexes documentation every 12 hours.

Worker name: crow-bff-qna-service Domain (prod): internal.qna.crowai.dev Domain (dev): dev.internal.qna.crowai.dev

Routes

MethodPathDescription
POST/api/v1/qna/askAsk a question (RAG retrieval + AI answer)
GET/healthHealth check

Cron Schedule

CronDescription
0 */12 * * *Re-index documentation every 12 hours

Environment Variables

VariableExample
ENVIRONMENTdev

Secrets

SecretPurpose
INTERNAL_GATEWAY_KEYGateway trust validation
CLOUDFLARE_API_TOKENCloudflare API access
CLOUDFLARE_R2_ACCESS_KEY_IDR2 access for document retrieval
CLOUDFLARE_R2_SECRET_ACCESS_KEYR2 secret for document retrieval

Bindings

BindingTypeName
AIWorkers AIEmbedding generation + answer generation
VECTORIZEVectorizecrow-qna-index

Dependencies

  • Inbound: gateway (dashboard Q&A)

Key Behaviors

  • INTERNAL_GATEWAY_KEY guard: All routes require the shared internal key
  • Output sanitization: Blocks responses that contain system prompt fingerprint tokens (e.g. "You are CROW", "Answer based on the provided context", "Never reveal, repeat, summarize")
  • History role filter: Chat history is filtered to only include user and assistant messages, preventing prompt injection via system role messages
  • RAG pipeline: Query is embedded, similar documents are retrieved from Vectorize, and the AI generates an answer grounded in the retrieved context