- Bridge server with LLM agent tool-use (search_kb, search_products, search_orders, search_inventory, escalate_human) - pgvector RAG knowledge base (95 FAQ chunks) - Auto opportunity creation in Twenty CRM - Auto follow-up task workflow - Chatwoot AgentBot integration (HMAC, webhook) - Docker compose infrastructure (PG18, Redis 8.8, node24-alpine) - Configuration templates (example files) - real secrets excluded via .gitignore
103 lines
3.3 KiB
YAML
103 lines
3.3 KiB
YAML
name: crm-ai-demo
|
||
|
||
# 共享基础设施:postgres(带 pgvector) + redis
|
||
# 应用层(Chatwoot / Twenty)用开源源码跑,不在此 compose 内。
|
||
#
|
||
# 分库:
|
||
# chatwoot — Chatwoot 业务数据(vector 扩展)
|
||
# twenty — Twenty CRM 数据
|
||
# products — Bridge 客服知识库 kb_docs(vector 扩展)
|
||
# Redis 分 db:chatwoot=db0, twenty=db1
|
||
#
|
||
# 端口均暴露到宿主,供本地源码应用 / docker 内应用经 host.docker.internal 连接。
|
||
|
||
services:
|
||
postgres:
|
||
image: pgvector/pgvector:pg18
|
||
container_name: crm-postgres
|
||
restart: always
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '0.5'
|
||
memory: 512M
|
||
ports:
|
||
- "5432:5432"
|
||
environment:
|
||
POSTGRES_USER: postgres
|
||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
|
||
POSTGRES_DB: postgres
|
||
volumes:
|
||
- pg-data:/var/lib/postgresql
|
||
- ./infra/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh:ro
|
||
healthcheck:
|
||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||
interval: 5s
|
||
timeout: 5s
|
||
retries: 10
|
||
|
||
redis:
|
||
image: redis:8.8-alpine
|
||
container_name: crm-redis
|
||
restart: always
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '0.3'
|
||
memory: 256M
|
||
ports:
|
||
- "6379:6379"
|
||
volumes:
|
||
- redis-data:/data
|
||
healthcheck:
|
||
test: ["CMD", "redis-cli", "ping"]
|
||
interval: 5s
|
||
timeout: 5s
|
||
retries: 10
|
||
|
||
# Chatwoot → LLM → Twenty CRM 销售桥接(源码 Docker 构建)
|
||
# 连同 compose 内的 postgres 共享网络;Chatwoot/Twenty 为独立 compose,经 host.docker.internal 访问。
|
||
bridge:
|
||
build: ./bridge
|
||
container_name: crm-bridge
|
||
restart: always
|
||
depends_on:
|
||
postgres:
|
||
condition: service_healthy
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '0.5'
|
||
memory: 512M
|
||
ports:
|
||
- "4000:4000"
|
||
environment:
|
||
PORT: "4000"
|
||
# 同 compose 网络,用容器名连 postgres(products 库存放客服知识库 kb_docs)
|
||
PG_URL: "postgres://postgres:postgres@crm-postgres:5432/products"
|
||
# Chatwoot / Twenty 为独立 compose,端口映射到宿主,容器经 host-gateway 访问
|
||
CW_BASE_URL: "http://crm-chatwoot-rails:3000"
|
||
TWENTY_BASE_URL: "http://crm-twenty-server:3000"
|
||
# AgentBot secret(HMAC 签名校验),由 register_agent_bot.js 生成
|
||
AGENT_BOT_SECRET: "REPLACE_WITH_AGENT_BOT_SECRET"
|
||
# 本地开发跳过 HMAC 签名校验(容器间网络安全,Sidekiq body 编码存在差异)
|
||
SKIP_AGENT_BOT_SIGNATURE: "true"
|
||
# 业务数据 API(Mock 服务器,宿主 localhost:9505)
|
||
INVENTORY_API_URL: "http://host.docker.internal:9505"
|
||
ORDER_API_URL: "http://host.docker.internal:9505"
|
||
extra_hosts:
|
||
- "host.docker.internal:host-gateway"
|
||
# 挂载源码与配置:改 server.js / *.config.json 后 docker restart crm-bridge 即可,无需 rebuild
|
||
volumes:
|
||
- ./bridge/server.js:/app/server.js:ro
|
||
- ./bridge/index_kb.js:/app/index_kb.js:ro
|
||
- ./bridge/register_agent_bot.js:/app/register_agent_bot.js:ro
|
||
- ./bridge/chatwoot.config.json:/app/chatwoot.config.json:ro
|
||
- ./bridge/llm.config.json:/app/llm.config.json:ro
|
||
- ./bridge/twenty.config.json:/app/twenty.config.json:ro
|
||
- ./bridge/kb.config.json:/app/kb.config.json:ro
|
||
|
||
volumes:
|
||
pg-data:
|
||
redis-data:
|