4D Blog

Home Tips Intelligent 4D Write Pro document analysis with AI

Intelligent 4D Write Pro document analysis with AI

September 2, 2025

Tips

In many business applications, users enter or receive unstructured text: customer feedback, internal notes, support tickets, reports, and more. This content represents valuable information, but it’s difficult to leverage without specific processing.

This is where artificial intelligence becomes a powerful tool: by automatically analyzing the written content of a 4D Write Pro document, it can extract useful metadata for understanding, sorting, or prioritizing.

In this demonstration, we’ve implemented a complete scenario of automatic analysis of 4D Write Pro documents using AI. From a simple text, the AI is capable of:

  • Generating a concise title reflecting the content
  • Identifying the tone (positive, negative, informative, urgent…)
  • Suggesting classification tags
  • Evaluating the document’s writing quality

The goal is clear: automatically enrich documents with usable metadata, without changing the user experience.

This feature is useful in many real-world situations:

  • Automatic sorting of incoming messages: based on tone and urgency
  • Document classification: by type, theme, or business domain
  • Detection of content to improve: low quality score = alert
  • Statistics on customer sentiment: track trends in feedback

How does it work?

The user types or pastes text into a 4D Write Pro-based interface. By clicking the “Save” button, the document is stored in the database and automatically analyzed via AI. The results of the analysis are then saved to the database and can be displayed in the interface to enrich the document.

HDI: Categorize 4D Write Pro documents

Here’s the metadata we want to extract automatically using AI:

  • Title: A concise title that reflects the subject and tone of the document
  • Tone: Positive, negative, neutral, informative, urgent, etc., with an emoji for quick visual reference
  • Tags: 1 to 3 business or thematic categories related to the content
  • Writing quality: A score out of 5 based on clarity, structure, and spelling, with an explanatory comment

 

Technical Details

1. Analysis triggered upon saving

When the user clicks the “Save” button, a method launches the document analysis via AI. Then it saves both the document and the AI-generated metadata in the database:

var $infos : Object
$infos := cs.ChatManagement.new().computeInfo(WP Get text($doc); $apiKey)

var $ent : cs.DocumentEntity
$ent:=ds.Document.new()
$ent.WP:=$doc
$ent.Title:=$infos.title
$ent.Tone:=$infos.tone
$ent.Tone_Emoji:=$infos.tone_emoji
$ent.Tags:=$infos.tags
$ent.Quality_Score:=$infos.quality_score
$ent.Quality_Comment:=$infos.quality_comment
$ent.save()

2. Prompt construction

The computeInfo method builds both the system prompt and the user prompt to query the AI.

The system prompt explains and guides the AI in its analysis and response. The user prompt contains only the 4D Write Pro document content to be analyzed.

$systemPrompt:="Analyze the following text and provide the following information: \n"
$systemPrompt+="1. Suggest a short and relevant title for the document..."
$systemPrompt+="...\n"
$systemPrompt+="Respond in the following JSON format (no balise code):\n"
$systemPrompt+="{\"title\": \"string\", ... }"

$messages.push({role: "system"; content: $systemPrompt})
$messages.push({role: "user"; content: $document})
$result:=cs.AIManagement.new($apiKey).generateInfo($messages)

return $result

3. OpenAI call class

The AIManagement class encapsulates the logic for calling OpenAI using the gpt-4o-mini model with 4D AIKit:

Class constructor($openAIKey : Text)
This.clientAI:=cs.AIKit.OpenAI.new($openAIKey)

Function generateInfo($messages : Collection) : Object
var $result:=This.clientAI.chat.completions.create($messages; {model: "gpt-4o-mini"})
return JSON Parse($result.choice.message.text)

4. Example AI result

Here’s an example of a response returned by the AI:

{
  "title": "Disappointment After Latest Product Update",
  "tone": "Negative",
  "tone_emoji": "😠",
  "tags": "Product Feedback, Software, Support",
  "quality_score": 5,
  "quality_comment": "Well-written and structured message, clear and professional."
}

Next

This demonstration shows how easily you can integrate an AI layer into your 4D Write Pro documents to automatically enrich them and extract structured data.

The model presented here is modular, adaptable, and reusable. It can be applied to various types of content, including emails, support tickets, internal notes, and user comments.

It integrates seamlessly into your existing 4D applications, without altering the user experience, while opening new possibilities for automation, sorting, and analysis. Here, AI acts as an invisible assistant, able to automatically enrich your documents and simplify their processing.

And you, what kind of intelligence would you like to add to your application or documents? Share your ideas, use cases, or questions on the 4D forum; the community is there to collaborate and inspire!

Discuss

Tags 20 R10, 21, 4D AIKit, 4D Write Pro, AI, Artificial Intelligence, OpenAI

Latest related posts

  • September 15, 2025

    Find the right spot in your 4D Write Pro document with AI

  • August 25, 2025

    ORDA – Constructor and touched event – Detailed behaviour through a network

  • August 13, 2025

    AI Brings Magical Search to 4D Write Pro Documents

Vanessa Talbot
Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor

Tags

4D-Analyzer 4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor
Subscribe to 4D Newsletter

© 2026 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy