Question title with artificial intelligence

htsumer

Active member
I plan to use AI to generate thread titles based on the topic in the xf_thread and xf_post tables, and then execute an SQL query to replace the old thread titles in xf_thread. I intend to do this through phpMyAdmin. Are there any risks involved? In short, I will give the xf_post message part to the AI, and it will prepare an SQL query to create the first message for this topic and add it to the xf_thread table.

Code:
✅ xf_thread

thread_id

title

first_post_id

✅ xf_post

post_id

thread_id

message (real content of the topic)

👉 The topic content on XenForo = xf_post.message
👉 Topic title = xf_thread.title
👉 Main content = xf_thread.first_post_id = xf_post.post_id

SELECT
  t.thread_id,
  t.node_id,
  t.title AS eski_baslik,
  LEFT(p.message, 2000) AS konu_icerigi
FROM xf_thread t
JOIN xf_post p ON p.post_id = t.first_post_id
WHERE p.message_state = 'visible'
LIMIT 10;
 
Last edited:
Upvote 0

Goal​


You want to:


  • Generate new, improved titles for each forum thread
  • Based on existing thread data (title, node, content if needed)
  • And update the xf_thread.title field automatically
  • For ~15,000 threads

Important XenForo Structure (Key Tables)​


In XenForo 2.x:


1. Thread titles​


Stored in:
Code:
xf_thread
Key column:
Code:
title

2. Thread content (first post text)​


Stored in:
Code:
xf_post
Important link:

Code:
xf_thread.first_post_id = xf_post.post_id
If you want smart / contextual titles, you MUST read from xf_post.message.




Recommended Architecture (Safe & Scalable)​


⚠️ Do NOT update titles directly with AI logic inside MySQL
MySQL is not designed for text generation.


Correct approach:​


  1. Extract data from MySQL
  2. Process titles externally (PHP / Python / AI)
  3. Write updated titles back to MySQL

STEP 1 – Extract Thread Data (MySQL)​


Basic extraction (title only)​


Code:
SELECT
    thread_id,
    title
FROM xf_thread
WHERE discussion_state = 'visible';

Advanced extraction (title + first post content)​




Code:
SELECT
    t.thread_id,
    t.title AS old_title,
    p.message AS first_post
FROM xf_thread t
JOIN xf_post p ON p.post_id = t.first_post_id
WHERE t.discussion_state = 'visible';

👉 Export this result as:


  • CSV
  • JSON
  • Or process directly via PHP/Python



STEP 2 – Generate New Titles (Outside MySQL)​


This is where AI or logic runs.


Example rules:​


  • Normalize titles
  • Expand abbreviations
  • Add clarity (Who / What / When)
  • Remove duplicated keywords
  • Limit to 120–150 characters (SEO friendly)

Example transformation:




Code:
Old: 657-Maaş Hesaplama-Hemşire
New: 657 Sayılı Kanuna Göre Hemşire Maaş Hesaplama Rehberi

Store results as:




Code:
thread_id | new_title



STEP 3 – Temporary Mapping Table (Recommended)​


Create a helper table to safely store new titles.




Code:
CREATE TABLE tmp_thread_titles (
    thread_id INT UNSIGNED PRIMARY KEY,
    new_title VARCHAR(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Insert generated titles:




Code:
INSERT INTO tmp_thread_titles (thread_id, new_title)
VALUES
(3, '657 Sayılı Kanuna Göre Hemşire Maaş Hesaplama Rehberi'),
(5, 'Aile Yardımı Ödeneğinde Özellik Arz Eden Durumlar'),
(...);



STEP 4 – Preview Before Update (CRITICAL)​


Always preview before applying changes.




Code:
SELECT
    t.thread_id,
    t.title AS old_title,
    tmp.new_title
FROM xf_thread t
JOIN tmp_thread_titles tmp ON tmp.thread_id = t.thread_id;

✔ Check length
✔ Check meaning
✔ Check duplicates




STEP 5 – Update Titles Safely​


Once verified:




Code:
UPDATE xf_thread t
JOIN tmp_thread_titles tmp ON tmp.thread_id = t.thread_id
SET t.title = tmp.new_title;



STEP 6 – Clean Up​


After success:




Code:
DROP TABLE tmp_thread_titles;



Performance & Safety Notes (VERY IMPORTANT)​


✅ Use batches for 15,000 rows​




Code:
UPDATE xf_thread t
JOIN tmp_thread_titles tmp ON tmp.thread_id = t.thread_id
SET t.title = tmp.new_title
LIMIT 500;

Repeat until complete.




✅ Backup first​




<span><span>mysqldump xf_thread &gt; xf_thread_backup.sql<br></span></span>
 
Some considerations:

Have you considered turning Discussion Thread Type into Question Thread Type IF the thread is a question ?

Have you considered feeding the LLM a list of google search queries and keywords popular in your niche, to prioritise? This would significantly enhance SEO.

Update tags, prefix and SEO meta description.
 
My main problem is that the subject lines aren't properly formatted. Short titles like "help," etc., are common. My aim is to make these and similar titles SEO-friendly. The question/subject content will remain the same anyway.
 
My main problem is that the subject lines aren't properly formatted. Short titles like "help," etc., are common. My aim is to make these and similar titles SEO-friendly. The question/subject content will remain the same anyway.
Is there a way to keep the visible thread titles the same (thread title changes tend to piss off the poster) while showing the search engines a more descriptive thread title.
 
My main problem is that the subject lines aren't properly formatted. Short titles like "help," etc., are common. My aim is to make these and similar titles SEO-friendly. The question/subject content will remain the same anyway.
Y ou might find this suggestion interesting:
 
Back
Top Bottom