Skip to main content

bff-chat-service

Backend for Frontend service powering the dashboard chat interface. Implements a CrewAI multi-agent system running in Workers Containers for AI-powered conversational access to all platform data. The TypeScript worker handles HTTP routing, chat history, and asset storage while the Python container handles tool-calling and reasoning.

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

Architecture

The chat service uses a two-tier architecture:

  1. TypeScript Worker -- Hono HTTP server managing chat sessions, message history (D1), and generated artifacts (R2)
  2. Python Container (ChatCrewContainer) -- CrewAI multi-agent crew running in a Workers Container via Durable Objects. Handles reasoning, tool calls, and response generation using @cf/meta/llama-3.3-70b-instruct-fp8-fast

Container Details

  • Class: ChatCrewContainer
  • Image: ./Dockerfile
  • Max instances: 3
  • Tools: The container calls back to the gateway API to fetch interactions, patterns, products, and organization context

Routes

Key routes (gateway path chat):

MethodPathDescription
POST/api/v1/chat/messagesSend a message and get AI response (streamed)
GET/api/v1/chat/historyGet chat message history
GET/api/v1/chat/sessionsList chat sessions
POST/api/v1/chat/sessionsCreate a new chat session
DELETE/api/v1/chat/sessions/{id}Delete a chat session

Environment Variables

VariableExample
ENVIRONMENTdev
API_GATEWAY_URLhttps://dev.api.crowai.dev

Bindings

BindingTypeName
DBD1crow-bff-chat-service-db
R2_BUCKETR2crow-bff-chat-service-store (artifacts, assets)
AIWorkers AILLM inference
CHAT_CREW_CONTAINERDurable ObjectChatCrewContainer (Workers Container)

Dependencies

  • Inbound: gateway (dashboard chat requests)
  • Outbound: gateway API (interactions, patterns, products, organizations -- via container tool calls)

Key Behaviors

  • Dashboard-specific: This is a BFF service, not a generic reusable service. It is designed specifically for the dashboard chat interface.
  • Streamed responses: Chat responses are streamed back to the client as they are generated
  • Artifact generation: The AI can produce artifacts (charts, summaries, tables) stored in R2
  • Multi-agent: The CrewAI crew dispatches work to multiple specialized agents concurrently

There is also a core-chat-service that provides basic chat history storage via D1. It uses Workers AI (@cf/meta/llama-3.3-70b-instruct-fp8-fast) for simple response generation without the CrewAI multi-agent architecture. Its D1 database is crow-core-chat-service-db.