Files
gochat/backend
rogee b769b9a3e4 Phase 2: AutoReplyRule integration + AgentBot Captain type
AutoReplyRule complete integration:
- bootstrap.go: instantiate AutoReplyRuleService + AutoReplyListener,
  register listener on channel dispatcher for message.created events
- router.go: register /captain/auto_reply_rules CRUD + /evaluate routes
- auto_reply_rule_handler.go: fix c.Param(id) → c.Param(account_id),
  override evalCtx.AccountID from path param
- auto_reply_rule_service.go: add JSON tags to AutoReplyEvaluationContext
  for correct request body binding
- auto_reply_listener.go (new): EventListener that triggers on incoming
  messages, evaluates active rules, composes reply (static/LLM/mixed),
  respects DelaySeconds and OneTimeOnly flags, sends via MessageService
- migration 000048: create captain_auto_reply_rules table

AgentBot + Captain integration:
- agent_bot_listener.go: add captainConvSvc field + SetCaptainConversationService
  method. In HandleEvent loop, check bot.BotType == captain and route
  to CaptainConversationService.BuildConversationResponseByAccount
  instead of webhook push. Extract assistant_id from bot.Config JSONB,
  extract conversation_id from event data.
- bootstrap.go: inject captainConversationService into agentBotListener

CaptainConversationService improvement:
- generateConversationResponse: use assistant config for system prompt,
  model name, and temperature instead of hardcoded values

Verified:
- go build ./... passes
- go vet passes on all internal packages
- go test passes (service + repository + llm, SQLite mode)
- Auto-reply CRUD: create/get/update/delete all work
- Auto-reply evaluate: correctly matches hello → should_reply=true,
  correctly rejects non-matching message
- Existing routes unaffected (assistants, RAG, conversation respond)
- Migration 000048 creates captain_auto_reply_rules table successfully
2026-07-08 15:38:08 +08:00
..