AI-Powered Citizen Intelligence Platform
Mataró City Council · Data Office
How we added two new dimensions of analysis — sentiment and criticality — to +35,000 citizen messages, with automatic daily updates and a conversational chatbot to query the state of the municipality in real time.

Data with context
Mataró City Council faced a silent challenge: they had data, but lacked context. They could classify citizen messages by channel, neighborhood, or topic, but they didn't know how their citizens felt or which situations were truly urgent.
Together with Optimtech, in 4 months they built an AI platform that adds two new dimensions to the analysis: sentiment and criticality, with automatic daily updates and a conversational chatbot to query the state of the municipality in real time.
The client
- Organization
- Mataró City Council
- Area
- Data Office
- Contacts
- Anna Quer i Rodríguez · Laura Sunyol Bert, Director of Innovation and Digital Transformation
- Internal users
- 5–10 people
- In production since
- February 2026
Mataró is a coastal city of over 130,000 inhabitants and one of the most innovative municipalities in Catalonia when it comes to digital transformation. The Data Office is the team responsible for turning municipal data into actionable intelligence to improve decision-making.
They knew what was being said, but not how or with what urgency
The City Council already had an internal dashboard that allowed them to classify incoming citizen messages across three dimensions: Channel (how the message arrived), Neighborhood (which area of the city), and Topic (what it was about).
But two key dimensions were missing to truly understand the pulse of the city:
Criticality
How urgent is the situation this citizen or family is experiencing? Is it a minor complaint or a critical situation requiring immediate attention?
Sentiment
What tone are citizens communicating in? Is there widespread frustration in a particular neighborhood? Are there topics that generate particular dissatisfaction?
Without these two dimensions, the team was making decisions with incomplete information. The trigger was clear: the innovation team realized that generative AI could automate this analysis with a precision that was previously impossible to scale manually, with over 35,000 accumulated messages and hundreds of new messages arriving every week.
4 months, 5 phases, a team of 3 people
The project was developed following a collaborative process with the City Council team.
Discovery and definition
We deeply understood how the Data Office worked, what data they had, how messages arrived, and exactly what gap they needed to fill. They didn't come with a predefined solution: we built the solution together.
Solution design
We defined the two dimensions of analysis (sentiment and criticality), their scales, interpretation criteria, and how they would integrate with the existing workflow. We also designed the data architecture and the anonymization model.
Development
Migration of 35,000+ historical messages, development of the analysis API with Azure OpenAI, implementation of the anonymization layer, development of the conversational chatbot with semantic search, and automation of the daily ingestion pipeline.
Tuning and validation
The most delicate phase of the project. We worked iteratively to fine-tune the LLM model until we obtained consistent and reliable results, and to eliminate chatbot hallucinations by ensuring responses were based exclusively on the municipality's real data.
Deployment and production
Deployment to Azure, configuration of daily automation, and training of the internal team.
A platform with three main components
Automatic analysis engine
Every morning, new citizen messages are automatically processed by a language model (GPT-4.1 on Azure OpenAI) that assigns a sentiment score (0–10), a criticality score (0–10), and automatically anonymizes all personal data.
Vector database
All messages are stored with vector embeddings, enabling semantic search (by meaning, not just keywords) across the 35,000+ messages in the history.
Real-time conversational chatbot
A chat interface where municipal technicians can ask in natural language: "What is the general sentiment this month in the Cirera neighborhood?" The system responds with real data, without making things up or hallucinating.

Stack technology
| Layer | Technology |
|---|---|
| AI and LLM | Azure OpenAI (GPT-4.1 + embeddings text-embedding-ada-002) |
| Database | PostgreSQL Flexible Server with pgvector extension |
| Backend | Node.js + TypeScript + Express |
| Frontend | React + TypeScript + Vite + Tailwind CSS |
| Infrastructure | Azure App Service + Azure Static Web Apps |
| Security | Azure Key Vault + JWT Authentication |
| Monitoring | Azure Application Insights |
Why these technical decisions
- Azure OpenAI instead of OpenAI directly: citizen data stays within the EU Azure environment, meeting data sovereignty and GDPR requirements.
- pgvector over standalone vector solutions: enables semantic search in the same relational database, reducing complexity and operational costs.
- Anonymization in the pipeline: before any data reaches the database, all personal data is automatically removed.
Challenges overcome
Sentiment analysis consistency
The biggest challenge was getting the LLM model to apply the analysis criteria consistently across thousands of messages with very different contexts. The solution required multiple iterations of prompt tuning, cross-validation with the City Council team, and definition of explicit interpretation criteria.
Hallucination-free chatbot
A chatbot on municipal data cannot make up information. We implemented a function-calling system where the model only has access to tools that query the real database, with no possibility of generating responses based on external knowledge.
Privacy and anonymization
The City Council placed special emphasis on ensuring no sensitive citizen data was stored. We developed an anonymization layer that automatically detects and replaces names, phone numbers, emails, and other personal data.
Measurable impact
+35,000 historical messages migrated, analyzed, and available for querying
Two new dimensions of analysis (sentiment and criticality) integrated into the existing workflow
Automatic daily pipeline: new messages are analyzed every morning without manual intervention
Real-time query of the municipality's emotional state via conversational chatbot
Platform in production since February 2026, in active use by the Data Office team
Full privacy compliance: zero personal data stored in the system
Citizen intelligence in real time
Most market solutions for public administration offer static and retroactive analysis. This platform offers something different:
The team can ask today how the city feels today, with data from this morning, in their own language (Spanish and Catalan), and get contextualized responses based on the municipality's complete history.
It's not a monthly report. It's not a dashboard with filters. It's a conversation with the city's data.
AI that transforms without disruption
This project demonstrates that AI applied to public management doesn't need to be disruptive to be transformative. Mataró City Council didn't change how they work: they added two layers of intelligence on top of what they already had, with a collaborative process, in a reasonable timeframe, and with a rigorous approach to privacy.
The result is a team that can now make decisions with more context, prioritize better, and understand the real pulse of their citizens.
Does your organization face the same challenges?
Let's talk about how we can help.
Request a conversation