Custom CRM Architecture: How to Build Self-Hosted AI Integration
Data layer, permissions, model access and audit logging. The architectural decisions that stop AI from being a box bolted on afterwards.
There is an easy way to add AI to a CRM: put a chat box on the screen and wire it to a model. It takes a week and demos well. In real use it gets abandoned within a few weeks, because the assistant does not know how the company actually works.
The version that works starts further down the stack. The four decisions below determine whether the result gets used at all.
1. The data layer: put meaning in the schema
For a model to work with your data, it must not have to guess at field names. In most legacy systems field names are abbreviations and the real meaning lives in institutional knowledge.
The right approach is to define, in machine-readable form, what each field means, which values it can take and which process fills it. That produces far more reliable results than sending long explanations to the model on every request.
2. Permissions: treat the agent as an actor
This is the most commonly skipped step. If an assistant acts on a user's behalf, it must not see data that user cannot see. The permission check belongs in the data access layer, not the application layer.
In practice that means the model query runs against a dataset already limited by that user's own session permissions. Otherwise the assistant becomes a side door through the access model you spent years building.
Put permissions in the application layer and the assistant eventually becomes a side door through them.
3. Model access: where will it run?
There are three options, and choosing means balancing security against capability:
- External provider API: the strongest models and the fastest start. Data leaves your estate, so contract terms are critical.
- Open model on your own infrastructure: data never leaves, hardware and maintenance are yours, and capability may lag slightly.
- Hybrid: sensitive work on the local model, general work through an external API. More complex to manage, but the most balanced option for most companies.
The decision depends on your sector and data sensitivity. What matters is making the choice part of the architecture from the start, because changing it later is expensive.
4. Audit logging: cover automated actions too
If an assistant updates records, opens tasks or sends email, all of it belongs in the audit log. Whose authority it acted under, which prompt triggered it and which data it read must all be traceable.
This is not only a compliance matter. On the first day the assistant does something wrong, being able to reconstruct what happened determines whether the system stays in use.
The order matters
These four should be built in sequence. Connecting a model while the data layer is still wrong just means producing fast wrong answers from bad data. Rolling out before permissions are settled is an invitation to a security incident.
A realistic order is this: fix the schema and its definitions first, extend the permission model to cover the agent, put the model into one narrow use case, and only then roll it out.
