Automatically moderate comments using AI

When you allow the general Internet to post comments, or any other kind of content, you're inviting spam and abuse. We see far more spam comments than anything relevant or useful -- but when there is something relevant or useful, we want to hear it!

With the AI module and the Events, Conditions, and Actions module, you can set up automatic comment moderation.

Like any use of AI, setting an appropriate prompt is crucial to getting a decent result. Here's the one we're trying out:

input:
  system_context:
    type: "text"
    description: "Instructions for gauging comment relevance"
    required: true
    value: "Analyze if the following comment is relevant to the 
    content it's responding to. Consider topical alignment,
     specific references, and whether it adds value to the discussion."

  entity_content:
    type: "text"
    description: "The content of the entity being commented on"
    required: true
    source: "[node:body]"

  entity_title:
    type: "text"
    description: "The title of the entity"
    required: true
    source: "[node:title]"

  comment_text:
    type: "text"
    description: "The comment text to be analyzed"
    required: true
    source: "[comment:body]"

output:
  relevance_score:
    type: "float"
    description: "Score from 0-1 indicating comment relevance"
    token: "[ai_eca:result:relevance_score]"
  
  is_relevant:
    type: "boolean"
    description: "Whether the comment is deemed relevant (score > 0.7)"
    token: "[ai_eca:result:is_relevant]"
  
  reasoning:
    type: "string"
    description: "Explanation of the relevance assessment"
    token: "[ai_eca:result:reasoning]"
  
  moderation_flag:
    type: "boolean"
    description: "Whether the comment was flagged for moderation"
    token: "[ai_eca:result:moderation_flag]"

The result returns an "is_relevant" flag if the AI is at least 70% confident the comment is relevant, we can then use that to automatically publish, or hold the comment for a human moderator.

(This is still in progress -- we will update this with a final working example).

Add new comment

The content of this field is kept private and will not be shown publicly.

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <blockquote cite> <cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h1> <h2 id> <h3 id> <h4 id> <h5 id> <p> <br> <img src alt height width>
  • Lines and paragraphs break automatically.