FNTP: an AI agent to go from accident statistics to a published article

Client
FNTP, the French National Federation of Public Works
Timeline
June to September 2025
Need
Turn CNAM accident statistics into prevention articles, with no technical skills required
What we did
A Shiny application with an AI agent and an editor that publishes to WordPress
Result
Delivered in 14 weeks, on the planned date. In use at FNTP.
Photo by Brandon Mowinkel on Unsplash

The client and the context

FNTP is the Fédération Nationale des Travaux Publics, the French federation of public works companies. Safety on construction sites is one of its core topics, and it wants its members to know the workplace accident figures in order to raise their awareness.

These figures are published by CNAM, the French national health insurance fund, in statistical sheets. For each public works activity, the sheets give the number of accidents, lost working days and permanent disabilities, broken down by age, type of injury or circumstance.

On this project, we worked with Damien, an independent consultant (DM Conseil), who led the engagement for FNTP and with whom we had worked before.

The problem

Getting from a statistical sheet to a published article takes several skills. Someone has to extract the right data, analyze it, write a text, produce a chart, then lay out the article and publish it. In an organization, these tasks rarely fall to the same person.

FNTP wanted a project officer to be able to do all of this alone, with no technical skills and in a single tool. It had also set the schedule from the start, with a delivery date 14 weeks after kickoff.

What we did

The application follows the project officer’s work in two steps.

In the first, they ask the AI agent a question, for example about the trend in accidents in a given activity. The agent returns a data table, a written analysis with its sources and tags, and a chart in the Federation’s colors. The project officer can edit everything, then saves this content.

Content creation screen: the conversation with the AI agent on the left, the data table, the sourced analysis and the chart on the right

In the second, they assemble their content in a built-in text editor, add images, adjust the wording and publish the article to WordPress without leaving the application.

Publication editor: an article assembled with its tags, its analysis and its chart, ready to be published on the FNTP website

Figures calculated from the sheets. A language model can write a wrong figure with great confidence, which is unacceptable when the subject is workplace accidents. The agent is therefore instructed to use only the available data. It writes the code that extracts the data, the application runs that code on the content of the sheets, and the table shown to the user is the result. The analysis and the chart start from that same table, and each result cited in the text is followed by its source. The project officer can see the data that backs what they are about to publish.

A single agent. We had first designed an orchestrator agent that split the work between specialized sub-agents, one for the data, one for the analysis, one for the chart. In testing, each sub-agent saw only part of the conversation, and their answers did not agree with each other. After a month, we merged everything into a single agent. Its instructions stayed at a reasonable size, and its behavior became more reliable and easier to tune.

The challenge: a feature missing from the package

The agent is built on ellmer and shinychat, two R packages released a few months before the project, which we were using for the first time.

Conversation history gave us the clearest problem. Users had to be able to reopen a past conversation with the agent to pick up a piece of content where they had left it, and version 0.2 of ellmer did not offer that feature.

We found a workaround in a discussion on the package’s GitHub repository, and we implemented it knowing it was temporary, in an isolated part of the code and with its documentation. When version 0.3 came out with the official feature, the application switched to it within the week.

With packages this recent, we follow their changes closely and keep each temporary solution in a place it can easily be removed from.

The results

The application was delivered fourteen weeks after kickoff, on the date FNTP had set during scoping. A project officer can start from a question about accident statistics and end with a published article, with its table, analysis and chart, without calling on an analyst or a webmaster, which was the original request.

Nine months later, Damien confirmed to us that the Federation was still using it.

Do you want to integrate an AI agent into a business application, or equip a workflow from end to end? Get in touch.