Skip to content

AI Administration

Everything on this page is for an administrator of the brand. A super administrator sees every brand and owns the shared (brand = "*") agents and templates.

Six screens cover the module. Only the first two are needed to run it.

Agents

An agent is a configuration: which model answers, with what instructions, which tools it may use, and how much it may spend per day.

MngGetAIAgentsByFilter lists them; MngAddAIAgent and MngUpdateAIAgent take these fields:

Field Meaning
name, description, enabled Identity and switch
modeChat may answer employees in backoffice and CRM
modeClient may answer clients in the terminal
modeWorkflow may generate notifications from events
model, fallbackModels[] Primary model and fallbacks, ids from MngGetAIModels
systemPrompt Role and tone, up to 20 000 characters
temperature, maxTokens Generation parameters
toolNames[] White list of tools; an empty list means no tools at all
knowledgeScopes[] Knowledge sections the agent may use
dailyRequestLimit, dailyTokenLimit, dailyCostLimit Daily caps; 0 disables a cap

Two of these deserve explanation in the interface, because they are set wrong by default otherwise.

The three modes are independent, and that is a safety boundary. An agent built for the backoffice has an internal system prompt and access to other people's accounts. Turning on modeClient for it would let the terminal reach that agent, so the flags are separate and the client mode is off by default.

The budgets are the only protection against a surprise invoice. The module counts every request, and when a cap is reached the agent answers with a controlled error instead of spending more. A daily cost limit of a few units of currency is enough for a stand.

The tool checkbox list comes from MngGetAITools: every tool reports whether its platform command is published on the bus right now (available). A tool whose command is missing simply is not offered to the model, so the whole list can be checked in advance — it will start working by itself when the platform publishes the command.

Prompt templates

Templates are the text the module fills for notifications and service prompts: MngGetAIPromptTemplatesByFilter, MngAddAIPromptTemplate, MngUpdateAIPromptTemplate, MngDeleteAIPromptTemplate.

A template has a type (notification, summary, classify, system), a language, and content with {{placeholders}}. The placeholders available for an event are listed by MngGetAIWorkflowEvents in variables.

MngTestAIPromptTemplate previews the substitution and reports unresolved placeholders. With run: true it also sends the result to the model and costs money — that has to be an explicit button, not a checkbox that is on by default.

Knowledge base

The knowledge base is files in the module repository, reviewed like code. The interface does not edit documents; it shows what the running service loaded and reloads it.

  • MngGetAIKnowledgeStatus — documents, chunks, per-brand breakdown, and errors with files that failed to parse. A non-empty errors deserves a visible marker: a document with broken front matter silently drops out of search.
  • MngGetAIKnowledgeDocuments — the loaded documents with language, audience and size.
  • MngReloadAIKnowledge — rebuilds the index in memory and swaps it atomically; active conversations do not notice.
  • AIKnowledgeSearch — the search as the assistant sees it, with scores. This is the first thing to look at when an answer is wrong: usually the document was not found, not that the model misbehaved.

Event bindings

A binding says: when this platform event arrives, this agent writes a text using this template, and it goes out through these channels.

MngAddAIWorkflowBinding and MngUpdateAIWorkflowBinding take eventName, agentId, promptTemplateId, enabled, cooldownSeconds, deduplicationWindowSec, delivery[] and a settings object:

settings key Meaning
filters[] { field, op, value } with eq, ne, in, notIn, gt, gte, lt, lte; field is validated against the event variables
quietHours { start, end } in hours 0–23, service time (UTC)
maxPerRecipientPerDay Per-recipient cap for this binding
requireApproval Whether a person must approve before delivery
fallbackText Ready text used if the model is unavailable

Only events with agreed: true can be bound — the rest are visible in the catalogue so it is clear what to ask the platform for, but the platform does not publish them.

MngTestAIWorkflowBinding is the screen that answers "why did nothing arrive": it takes a sample payload and shows, per binding, whether it would fire, the suppression reason, the recipient, whether approval is needed and the exact prompt. It sends nothing and stores nothing.

Spend

MngGetAIUsageByFilter groups by day, agent, model, brand, day-agent or day-model and returns requests, inputTokens, outputTokens, tokens, cost, errors, toolCalls, avgLatencyMs and errorRate, plus totals in the same shape.

Average latency is restored from a sum rather than stored as an average — averages cannot be added across rows of an aggregate.

Audit

  • MngGetAIRunsByFilter — the run journal, filterable by state.
  • MngGetAIRunDetails — one run with its sources, tool calls and spend. Opening it writes a line to the service log: reading someone else's conversation is an incident review, not browsing.
  • MngGetAIFeedbackByFilter — ratings, with comments. Negative ones are the working list for improving prompts and the knowledge base.

Service state

AIPing is a cheap probe with a list of problem codes. AIHealth adds the whole picture: database, knowledge index, model latency and errors, tool counters, notification counters, maintenance, spend for the last 24 hours, and a platform block listing platform commands the module needs but does not see on the bus.

That platform block is worth surfacing in the interface. When it is not ok, some tools are silently unavailable, and the cause is the platform build rather than the module.