Building Newsroom AI Modules in PHP

Most people think AI in a newsroom means one big chat box. This is a mistake. That model leads to features that people use once and then ignore.

A newsroom has dozens of small, specific needs. You need headline options. You need social media blurbs. You need SEO titles. You need entity tagging. Each job is small but has its own rules.

After working with 200 news sites, I found the right way to build this. Do not build one "AI feature." Build a registry of small, specialized workflows.

Here is how to do it in PHP:

  • Use tasks, not prompts. A task is a named unit with a fixed contract. It knows what it needs and what it returns.
  • Validate output inside the task. Models often return text when you want JSON. If the task validates its own output, you can retry or fail gracefully without breaking your editor.
  • Use a tier-based router. Run simple tasks on cheap models. Run legal or risk tasks on premium models.
  • Cache by task and input. If an editor clicks a button twice on the same article, you should not pay for a second AI call. Caching is your best cost control.
  • Keep rules in code and taste in prompts. Do not ask a model to check if a headline is under 70 characters. Use PHP for that. Use the model to decide if the headline is good. Code handles rules. Models handle judgment.

Group your tasks to keep things organized:

• Headlines: SEO titles, social blurbs, push notifications. • Structure: Summaries, key points, read more suggestions. • Classification: Category suggestions, tag extraction. • Media: Alt text, captions, crop hints. • Quality: Tone checks, risk flags, profanity filters.

The goal is operational reliability. If an AI provider goes down during a busy news day, you should change a config file, not rewrite your code.

Two final rules for success:

  1. Suggestions are drafts. Never let AI write directly to a published field. A human must always review and accept the output.
  2. Work in the background. If a task takes more than one second, run it as an async job. Do not make your editors wait for a loading screen.

Build the architecture first. The model is secondary.

Source: https://dev.to/mahmut_gndzalp_c736ac4b/building-newsroom-ai-modules-in-php-50-specialized-workflows-2co1