apps/ai-agents), that hosts the LLM agent runtime and executes CRM tools by calling the backend Agents API (/api/agents/*).
When you need it
Useapps/ai-agents when you want:
- The agent runtime to run as a standalone service (separate from the NestJS backend)
- Tool execution to happen through the backend’s agent-scoped endpoints (
/api/agents/*)
Environment variables
apps/ai-agents reads:
BACKEND_URL: Backend base URL (example:http://localhost:3001)AGENT_TOKEN: Shared token used to authenticate requests to/api/agents/*OPENAI_API_KEYandOPENAI_MODEL: Model credentials/config for the agent runtime
AGENT_TOKEN configured so it can validate requests.
Run locally
How tool calls reach the backend
apps/ai-agents uses apps/ai-agents/src/shared/backend.ts to call the backend.
Requests include:
x-agent-token: must matchAGENT_TOKENon the backendx-org-id: the active organization ID (required for CRM operations)x-user-id: optional (used when tools default ownership to the current user)
AgentGuard validates the token and sets request.organizationId from x-org-id, so routes can keep using @OrgId().
Available CRM tools
The ai-agents runtime exposes CRM tools:Companies
get_company_detailsquery_companiescreate_companyupdate_company
Contacts
get_contact_detailsget_contact_ownerquery_contactscreate_contactupdate_contact
Deals
get_deal_detailsquery_dealscreate_dealupdate_deal
Context
get_conversation_context: lists the contact/company/deal IDs currently attached as context in the conversation