# Build a controlled Analytics Assistant with LangChain, Qdrant, and Regolo

This tutorial shows how to build an analytics AI agent that retrieves KPI definitions with Qdrant, queries structured metrics through governed tools, and prepares approval-gated CRM actions—running on Regolo's OpenAI-compatible European AI inference API.

## TL;DR

- **What:** a production-oriented analytics agent with tool calling, not another "chat with your docs" demo.
- **Stack:** LangChain (orchestration) + Qdrant (vector retrieval) + Regolo (OpenAI-compatible LLM inference) + Python.
- **What it does:** retrieves metric definitions, queries weekly activation data, explains the largest decline, and creates a non-destructive CRM follow-up list.
- **What it does NOT do:** send messages, modify CRM records, or run arbitrary queries against production systems.
- **Who it's for:** CTOs, Heads of AI, platform and ML engineers building enterprise agents on European infrastructure.

## The problem: analytics questions are not single-source questions

A typical analytics request looks like this:

> Why did activation drop last week, and which accounts should we follow up with?

Answering it reliably requires more than one data source. You need the **definition** of the metric (documentation), the **data** itself (warehouse or BI), and a **next step** (CRM or workflow tool). A chatbot over documents can only cover the first part. A raw text-to-SQL agent covers part of the second—unsafely. The missing piece is a controlled pattern that combines all three.

### What this analytics agent does

The example handles one concrete business request:

> Compare activation in 2026-W29 with 2026-W28, explain the largest decline using our KPI definition, and prepare a CRM follow-up list.

The agent uses three controlled tools:

1. **Knowledge retrieval with Qdrant** — retrieves metric definitions, business policies, and CRM operating rules.
2. **A read-only metrics tool** — returns approved KPI data from a BI system, warehouse, or analytics API.
3. **A constrained CRM tool** — creates a follow-up list but cannot send messages, modify records, or change ownership.

In the supplied demo data, Self-serve activation drops from 45% (54/120) to 30% (39/130)—a 15 percentage-point decline—while Sales-led holds steady. The agent identifies this, grounds its explanation in the retrieved glossary, and prepares a follow-up list for the affected segment.

**The key design principle:** the LLM chooses *which* permitted tool to call. Your application defines *what each tool can do*.

## Architecture

```
Business user
   ↓
LangChain agent
   ↓
Regolo OpenAI-compatible inference API
   ↓ tool calling
 ┌─────────────────────────────────────────────┐
 │ Qdrant: policies, KPI glossary, documentation│
 │ Metrics API: governed, read-only KPI queries │
 │ CRM API: approval-gated follow-up lists      │
 └─────────────────────────────────────────────┘
   ↓
Grounded KPI analysis and controlled next action
```

Qdrant supports local on-disk operation as well as server and cloud deployments; the local mode makes this guide runnable without provisioning vector infrastructure.

## Why Regolo

Regolo provides an OpenAI-compatible inference API: existing applications built with OpenAI-compatible SDKs and agent frameworks can typically be pointed at Regolo by changing the API key, base URL, and model name—without rewriting the application architecture. For European teams, this means integrating AI agents into production workflows on European GPU infrastructure, without operating your own model serving stack.

## Prerequisites

- Python 3.10 or later
- Docker and Docker Compose
- a Regolo account and API key
- a Regolo model that supports tool/function calling
- exported CSV, XLS, or TXT files from Google Analytics, Matomo, a BI platform, or another approved source

## Install the project

Clone the repository and enter the tutorial directory:

```
git clone https://github.com/regolo-ai/tutorials.git
cd tutorials/analytics-assistant-chromadb-qdrantCode language: Bash (bash)
```

Make the setup script executable:

```
chmod +x ./setup.shCode language: Bash (bash)
```

Run the environment setup:

```
./setup.shCode language: Bash (bash)
```

The setup script creates the local environment, installs dependencies, and starts the required Qdrant service.

## Configure Regolo

Create a Regolo account and generate an API key from the dashboard. Then add the key and model name to `.env`:

```
REGOLO_API_KEY=your_regolo_api_key
REGOLO_MODEL=your_tool_calling_model
REGOLO_BASE_URL=https://api.regolo.ai/v1Code language: Bash (bash)
```

Check the Regolo documentation for current model availability and which models support tool/function calling.

## Run the assistant

```
./dev.shCode language: Bash (bash)
```

Choose option `1` to complete the initial environment setup. If Qdrant variables are missing from `.env`, select option `2`. Then choose **Run application** and select the directory containing your exported analytics data. The assistant uses CSV, XLS, or TXT files as the input layer for the demonstration workflow.

![](https://regolo.ai/wp-content/uploads/2026/07/Screenshot-2026-07-28-alle-11.37.45-1024x467.png)[Sign up to get 30 days free account](https://regolo.ai/signup), and generate your api key and set `REGOLO_API_KEY` and a tool-calling model available in your Regolo account. Regolo’s OpenAI-compatible base URL is `https://api.regolo.ai/v1`, and LangChain can connect through `ChatOpenAI`, everything to know about regolo setup you can find in our [docs](https://docs.regolo.ai).

Once you setup the regolo api key, you're ready to launch `dev.sh` that will show you this menu to guide you through into the environment setup automatically runningn the first selection (1).

![](https://regolo.ai/wp-content/uploads/2026/07/Screenshot-2026-07-28-alle-11.51.05-1024x537.png)Complete the setup environment downloading the Qdrant docker, install all modules and activated local env you can type the option 2 to setup the missing Qdrant variables in the `.env` file.

![](https://regolo.ai/wp-content/uploads/2026/07/Screenshot-2026-07-28-alle-11.51.20.png)Selecting the "Run application" and selecting the folder where you exported XLS, CSV, TXT data from Google Analytics, Matomo or BI you can query what you need to know and define the output to make the output actionable.

![](https://regolo.ai/wp-content/uploads/2026/07/Screenshot-2026-07-28-alle-13.44.01-1024x370.png)### All your data company are safe and private, without using any anonimizer in the middle, and getting smarter query by query acquiring real data of business and avoiding model allucinations. 

---

## From demo to production

Before connecting real company data, add these layers:

- **Read-only analytics access:** replace the demo data with a governed analytics service that enforces tenant, role, and date filters. Never give the model direct warehouse credentials.
- **Scoped CRM actions:** keep the write surface minimal. Messaging, record changes, and ownership updates require explicit human approval.
- **Authorization, not just retrieval:** vector retrieval is not an authorization system. Enforce document-level permissions before content reaches the model.
- **Observability:** log tool inputs, outputs, caller identity, and approval IDs.

---

## Privacy and reliability

This architecture is designed to reduce unnecessary exposure of company data and make agent behavior easier to inspect. Qdrant stores and retrieves relevant business context, while dedicated tools constrain access to metrics and business systems.

Retrieval and tool calling do not guarantee correctness by themselves. Production deployments should add role-based access control, document-level permissions, logging, output validation, evaluation datasets, and human approval for external or irreversible actions. Before processing sensitive data, validate your deployment configuration, data handling requirements, retention settings, and internal security policies.

---

## Frequently Asking Questions

## What is an analytics AI agent?

An analytics AI agent is an application that uses an LLM to interpret a business request, retrieve relevant definitions and context, query approved data sources, and return an evidence-based answer or controlled next action.

## Why use LangChain for tool calling?

LangChain provides building blocks for connecting an LLM to tools such as retrievers, APIs, databases, and internal workflows. In this tutorial, it coordinates retrieval, metric queries, and a limited CRM action.

## Why use Qdrant in an analytics agent?

Qdrant stores semantic representations of unstructured business knowledge such as KPI glossaries, operating procedures, documentation, and policies. The agent retrieves this context before interpreting metrics or proposing an action.

## Why use Regolo for AI agents?

Regolo provides an OpenAI-compatible inference API for teams that need to integrate AI models into existing applications and agent frameworks—using standard tooling while selecting models and deployment options appropriate to their technical and compliance requirements.

## Does RAG eliminate hallucinations?

No. RAG improves grounding by retrieving relevant source material, but it does not guarantee factual accuracy. Production systems need tool constraints, validation, monitoring, evaluations, and human review for high-impact decisions.

## Can the agent write directly to a CRM?

It can, but this tutorial intentionally limits the CRM capability to creating a follow-up list. Messaging, record changes, ownership changes, and other irreversible actions should require explicit approval and separate authorization controls.

---

## Github Code

In our repository you'll find all tutorial codes and clicking below the full tested and working codes of this guide.

[Download Codes](https://github.com/regolo-ai/tutorials/tree/main/analytics-assisant-chromadb-qdrant)

---

## Ship Private AI. Not Infrastructure.

You have the private RAG architecture. Now give it an inference layer built for production.

**Regolo** gives European teams fast, OpenAI-compatible access to Mistral, Llama, Qwen, DeepSeek, GLM, and more — with zero data retention, EU data residency, and no new SDK to learn.

Change your `base_url`. Keep your LangChain code. Start shipping.

### 🚀 [Start your 30-day free trial →](https://regolo.ai/?utm_source=blog&utm_medium=cta&utm_campaign=private-rag)

Build, test, and deploy with no infrastructure to maintain.
**No credit card. No migration project. No compromise on data control.**

### 💬 [Join the Regolo Discord →](https://discord.gg/bqGrVJHeF)

Meet builders working on private RAG, local LLMs, LangChain, Ollama, and production AI systems. Share your setup, get feedback from the community, and speak directly with the Regolo team.

### 🤝 [Talk to an AI Infrastructure Engineer →](https://regolo.ai/contact?utm_source=blog&utm_medium=cta&utm_campaign=private-rag)

Running a sensitive workload, scaling beyond a proof of concept, or assessing a managed EU inference provider? Get a tailored architecture and commercial proposal for your team.

### 📂 [Clone the GitHub repository →](https://github.com/regolo-ai/tutorials/)

Get the full implementation from this guide: ingestion scripts, ChromaDB setup, hybrid retrieval, the **30-Question RAG Floor**, evaluation examples, and deployment configuration.

> **Private AI should not require a private data center.**
> Regolo gives your team an EU-native path from local experimentation to production-grade inference.

---

### Build with Regolo

- **Discord:** [Join the community →](https://discord.gg/bqGrVJHeF)
- **GitHub:** [Explore open-source workflows →](https://github.com/regolo-ai/tutorials/)
- **X / Twitter:** [Follow @regolo\_ai →](https://x.com/regolo_ai)
- **Reddit:** [Join the community →](https://www.reddit.com/r/regolo_ai/)
- **Documentation:** [Read the API docs →](https://docs.regolo.ai)
- **Contact:** [Talk to the team →](https://regolo.ai/contact)

---

*Built with ❤️ by the Regolo team. Questions? [regolo.ai/contact](https://regolo.ai/contact)* or chat with us on [Discord](https://discord.gg/bqGrVJHeF)