> ## Documentation Index
> Fetch the complete documentation index at: https://memberpulseptyltd.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Content Generator

> AI-powered content generation to drive member engagement based on interest categories

Generate engaging content automatically based on platform Interest Categories to encourage member participation and community engagement.

## Capabilities

| Action                  | ROLE\_CLIENT\_ADMIN | ROLE\_CLIENT\_USER |
| ----------------------- | ------------------- | ------------------ |
| View generated content  | ✅                   | ✅                  |
| Configure generation    | ✅                   | ❌                  |
| Approve/reject content  | ✅                   | ❌                  |
| Manage categories       | ✅                   | ❌                  |
| View engagement metrics | ✅                   | ✅                  |

## Features

### Interest Categories

Define categories that reflect member interests:

<Steps>
  <Step title="Create Category">
    Add interest category with name and description

    Examples:

    * Industry Trends
    * Regulatory Updates
    * Professional Development
    * Technology & Innovation
    * Best Practices
  </Step>

  <Step title="Configure Keywords">
    Add keywords and topics for AI content generation
  </Step>

  <Step title="Set Generation Rules">
    Configure content quantity (default: 5 per category)
  </Step>
</Steps>

#### Acceptance Criteria

##### Frontend

* [ ] Interest Category management (CRUD)
* [ ] Approve/reject actions with bulk operations
* [ ] Publication scheduling calendar

##### Backend / API

* [ ] Backend behavior supports this feature as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] Minimum 1 Interest Category required for generation
* [ ] Members only see content matching their interests
* [ ] Comments notify other interested members of activity

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

### Content Generation

The system generates content items for each Interest Category:

<Tabs>
  <Tab title="Generation Settings">
    * **Items per Category**: Number of content pieces (default: 5)
    * **Content Types**: Articles, discussion starters, polls, quick tips
    * **Tone**: Professional, conversational, thought-provoking
    * **Length**: Short (100-200 words), Medium (300-500 words)
    * **Generation Frequency**: Daily, weekly, on-demand
  </Tab>

  <Tab title="AI Configuration">
    * **Topic Focus**: Keywords and themes per category
    * **Industry Context**: Organization-specific terminology
    * **Engagement Style**: Question-based, opinion-seeking, informative
    * **Compliance Filters**: Content guidelines and restrictions
  </Tab>
</Tabs>

#### Acceptance Criteria

##### Frontend

* [ ] Content generation configuration panel
* [ ] AI content generation trigger button
* [ ] Content review queue with preview
* [ ] Inline editing of generated content

##### Backend / API

* [ ] Backend behavior supports this feature as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] Maximum 10 items per category per generation run
* [ ] Content must be approved before publication
* [ ] Generated content tagged as "AI-assisted" for transparency
* [ ] Engagement metrics tracked per content item
* [ ] Polls enforce one vote per member (and optional vote-change rules if enabled).
* [ ] Discussion content supports threaded replies.

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

### Content Approval Workflow

```
Generated → Pending Review → Approved/Rejected → Published → Nominated
```

<Steps>
  <Step title="AI Generates Content">
    System creates \~5 content items per active category
  </Step>

  <Step title="Admin Review">
    Review queue shows generated content for approval
  </Step>

  <Step title="Edit & Approve">
    Admin can edit, approve, or reject each item
  </Step>

  <Step title="Schedule Publication">
    Set publish date/time or publish immediately
  </Step>

  <Step title="Member Nomination">
    System nominates content to members with matching interests
  </Step>
</Steps>

#### Acceptance Criteria

##### Frontend

* [ ] UI supports the workflows described in this feature.

##### Backend / API

* [ ] Backend behavior supports this feature as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] All business rules for this feature are enforced.

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

### Member Nomination

When content is published:

1. System identifies members with matching Interest Category preferences
2. Nominated content appears in member's personalized feed
3. Push notification / email sent to engaged members
4. Content highlighted as "Recommended for You"

#### Acceptance Criteria

##### Frontend

* [ ] Member nomination preview (who will see content)

##### Backend / API

* [ ] Backend behavior supports this feature as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] Nomination respects member notification preferences

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

### Engagement Features

Content items support:

* **Comments**: Members can share opinions and insights
* **Reactions**: Like, insightful, agree, disagree
* **Sharing**: Share to other members or external
* **Bookmarking**: Save for later
* **Activity Notifications**: Alert interested members of new activity

#### Acceptance Criteria

##### Frontend

* [ ] Engagement metrics dashboard

##### Backend / API

* [ ] Backend behavior supports this feature as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] All business rules for this feature are enforced.

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

## Implementation Contracts

### Backend (API)

```
# Interest Categories
GET    /api/community/categories                    # List categories
POST   /api/community/categories                    # Create category
PUT    /api/community/categories/{id}               # Update category
DELETE /api/community/categories/{id}               # Delete category

# Content Generation
POST   /api/community/content/generate              # Trigger generation
GET    /api/community/content/pending               # Pending review queue
GET    /api/community/content                       # All content
GET    /api/community/content/{id}                  # Content details
PUT    /api/community/content/{id}                  # Edit content
POST   /api/community/content/{id}/approve          # Approve content
POST   /api/community/content/{id}/reject           # Reject content
POST   /api/community/content/{id}/publish          # Publish content
DELETE /api/community/content/{id}                  # Delete content

# Generation Settings
GET    /api/community/settings                      # Get settings
PUT    /api/community/settings                      # Update settings

# Engagement Metrics
GET    /api/community/content/{id}/metrics          # Content engagement
GET    /api/community/analytics                     # Overall analytics
```

**Generate Request:**

```json theme={null}
{
  "categoryIds": ["uuid-1", "uuid-2"],  // Optional: specific categories
  "itemsPerCategory": 5,
  "contentTypes": ["article", "discussion", "poll"],
  "schedulePublish": false
}
```

**Generated Content Response:**

```json theme={null}
{
  "id": "content-uuid",
  "categoryId": "category-uuid",
  "categoryName": "Industry Trends",
  "title": "The Future of Professional Certifications",
  "body": "As industries evolve...",
  "contentType": "discussion",
  "engagementPrompt": "What changes have you seen in certification requirements?",
  "status": "pending",
  "generatedAt": "2025-01-15T10:30:00Z",
  "nominatedMemberCount": 234
}
```

### Notification Triggers

| Event                               | Notification                                | Preference             |
| ----------------------------------- | ------------------------------------------- | ---------------------- |
| New content in interest area        | "New article in \[Category] you might like" | contentRecommendations |
| Comment on content you engaged with | "\[Member] commented on \[Title]"           | commentNotifications   |
| High engagement on interest topic   | "Trending in \[Category]: \[Title]"         | trendingAlerts         |
| Reply to your comment               | "\[Member] replied to your comment"         | commentNotifications   |

<Note>
  All notifications respect member opt-out preferences. Members who have set `communityOptOut: true` will not receive any community notifications regardless of individual settings.
</Note>

### Data Model

```typescript theme={null}
interface InterestCategory {
  id: string;
  name: string;
  description: string;
  keywords: string[];
  active: boolean;
  contentCount: number;
  memberCount: number;  // Members with this interest
  displayOrder: number;
  createdAt: string;
  updatedAt: string;
}

interface GeneratedContent {
  id: string;
  categoryId: string;
  title: string;
  body: string;
  contentType: 'article' | 'discussion' | 'poll' | 'tip';
  engagementPrompt?: string;  // Question to encourage comments
  
  // Status
  status: 'pending' | 'approved' | 'rejected' | 'published';
  reviewedBy?: string;
  reviewedAt?: string;
  rejectionReason?: string;
  
  // Publication
  publishedAt?: string;
  scheduledFor?: string;
  
  // Engagement
  viewCount: number;
  commentCount: number;
  reactionCount: number;
  shareCount: number;
  
  // AI metadata
  aiModel: string;
  generatedAt: string;
  
  createdAt: string;
  updatedAt: string;
}

interface ContentComment {
  id: string;
  contentId: string;
  memberId: string;
  memberName: string;
  body: string;
  parentCommentId?: string;  // For replies
  reactionCount: number;
  createdAt: string;
  updatedAt: string;
}

interface ContentNomination {
  id: string;
  contentId: string;
  memberId: string;
  reason: 'interest_match' | 'engagement_history' | 'trending';
  notified: boolean;
  notifiedAt?: string;
  viewed: boolean;
  viewedAt?: string;
  engaged: boolean;  // Commented, reacted, or shared
  createdAt: string;
}
```

### Error Handling

| Error                    | HTTP Status | Message                                      |
| ------------------------ | ----------- | -------------------------------------------- |
| No categories configured | 400         | "At least one Interest Category required"    |
| Generation in progress   | 409         | "Content generation already running"         |
| AI service unavailable   | 503         | "Content generation temporarily unavailable" |
| Content not found        | 404         | "Content not found"                          |
| Already published        | 400         | "Cannot modify published content"            |

### Engagement Metrics

| Metric               | Description                          |
| -------------------- | ------------------------------------ |
| View Rate            | Views / Nominations × 100            |
| Engagement Rate      | (Comments + Reactions) / Views × 100 |
| Share Rate           | Shares / Views × 100                 |
| Comment Depth        | Average replies per comment thread   |
| Category Performance | Engagement by interest category      |

## RSS Feed Integration

The client/association can provide RSS feeds that the AI will read through daily to stay current with industry news and trends.

### Feed Configuration

<Steps>
  <Step title="Add RSS Feeds">
    Configure RSS feed URLs from industry publications, news sources, and relevant websites
  </Step>

  <Step title="Set Categories">
    Map each feed to one or more Interest Categories for targeted content generation
  </Step>

  <Step title="Configure Frequency">
    Set how often the system reads and processes each feed (hourly, daily, weekly)
  </Step>

  <Step title="Enable AI Processing">
    Activate AI to analyze feed content and generate engagement content
  </Step>
</Steps>

### Feed Management

* **Multiple Feeds**: Add unlimited RSS feed sources
* **Feed Health Monitoring**: System alerts if feeds become unavailable
* **Content Filtering**: Keywords to include/exclude certain topics
* **Source Attribution**: Generated content references original articles

#### Acceptance Criteria (RSS Feeds)

##### Frontend

* [ ] RSS feed management interface
* [ ] Feed URL validation on entry
* [ ] Feed health status indicators
* [ ] Category mapping for each feed
* [ ] Feed content preview

##### Backend / API

* [ ] RSS feed parser and reader
* [ ] Scheduled feed processing jobs
* [ ] Feed content storage and indexing
* [ ] Feed health monitoring and alerts

##### Permissions

* [ ] Only `ROLE_CLIENT_ADMIN` can add/edit/remove RSS feeds

##### Business Rules

* [ ] Feeds processed according to configured frequency
* [ ] Duplicate content detection across feeds
* [ ] Failed feed reads logged and retried

##### Error Handling

* [ ] Invalid feed URLs rejected with clear error
* [ ] Unavailable feeds trigger admin notification

## AI-Generated Debate Content

Based on the regularity setting configured by the client/association, the system uses data from RSS feeds to generate controversial and hot topic debate threads or polls.

### Regularity Configuration

| Setting   | Description                             |
| --------- | --------------------------------------- |
| Daily     | Generate debate content every day       |
| Weekly    | Generate debate content once per week   |
| Bi-weekly | Generate debate content every two weeks |
| Monthly   | Generate debate content once per month  |
| On-demand | Only generate when manually triggered   |

### Generated Content Types

<CardGroup cols={2}>
  <Card title="Debate Threads" icon="comments">
    Discussion starters on controversial or trending topics designed to spark member engagement
  </Card>

  <Card title="Hot Topic Polls" icon="square-poll-vertical">
    Quick polls on current industry issues to gauge member opinions
  </Card>
</CardGroup>

### Debate Thread Generation

AI analyzes RSS feed content to identify:

* **Controversial Topics**: Issues with multiple valid perspectives
* **Trending Discussions**: Topics gaining traction in the industry
* **Policy Changes**: Regulatory or industry changes affecting members
* **Opinion Pieces**: Topics suitable for member debate

Generated threads include:

* Compelling headline/title
* Context paragraph explaining the topic
* Balanced presentation of different viewpoints
* Open-ended question to prompt discussion

### Poll Generation

AI creates polls based on current topics:

* **Opinion Polls**: "Do you agree with \[policy/trend]?"
* **Prediction Polls**: "What do you think will happen with \[issue]?"
* **Preference Polls**: "Which approach do you prefer for \[topic]?"
* **Priority Polls**: "Rank these issues by importance"

#### Acceptance Criteria (Debate Content)

##### Frontend

* [ ] Regularity setting selector in content generator settings
* [ ] Preview of AI-generated debate threads before approval
* [ ] Poll builder with AI-suggested options
* [ ] Content calendar showing scheduled generations
* [ ] RSS source attribution on generated content

##### Backend / API

* [ ] Scheduled job based on regularity setting
* [ ] AI analysis of RSS feed content for topic extraction
* [ ] Debate thread generation with balanced viewpoints
* [ ] Poll generation with relevant options

##### Permissions

* [ ] Only `ROLE_CLIENT_ADMIN` can configure regularity settings
* [ ] Generated debate content requires approval before publishing

##### Business Rules

* [ ] Content generated according to regularity schedule
* [ ] All generated content goes through approval workflow
* [ ] Source articles cited in generated content
* [ ] Content respects organization's topic guidelines/restrictions
* [ ] Polls enforce configurable voting rules (single vote, vote change allowed, etc.)

##### Error Handling

* [ ] If insufficient RSS content, system notifies admin
* [ ] Generation failures logged with retry option
* [ ] Content moderation flags potentially inappropriate topics

### Implementation Contracts (RSS & Debates)

```
# RSS Feed Management
GET    /api/community/feeds                     # List configured feeds
POST   /api/community/feeds                     # Add RSS feed
PUT    /api/community/feeds/{id}                # Update feed
DELETE /api/community/feeds/{id}                # Remove feed
GET    /api/community/feeds/{id}/status         # Check feed health
POST   /api/community/feeds/{id}/test           # Test feed parsing

# Debate Content Generation
GET    /api/community/settings/regularity       # Get regularity setting
PUT    /api/community/settings/regularity       # Update regularity
POST   /api/community/debates/generate          # Manually trigger generation
GET    /api/community/debates/pending           # Pending debate content
GET    /api/community/debates/calendar          # Generation schedule
```

**RSS Feed Configuration:**

```json theme={null}
{
  "id": "feed-uuid",
  "name": "Industry News Daily",
  "url": "https://example.com/rss",
  "categoryIds": ["category-uuid-1", "category-uuid-2"],
  "frequency": "daily",
  "keywords": {
    "include": ["regulation", "certification"],
    "exclude": ["advertisement"]
  },
  "active": true,
  "lastProcessed": "2025-01-15T06:00:00Z",
  "status": "healthy"
}
```

**Generated Debate Thread:**

```json theme={null}
{
  "id": "debate-uuid",
  "type": "discussion",
  "title": "Should Professional Certifications Require Annual Renewal?",
  "body": "Recent industry discussions have reignited the debate...",
  "viewpoints": [
    {
      "position": "For annual renewal",
      "summary": "Ensures practitioners stay current..."
    },
    {
      "position": "Against annual renewal",
      "summary": "Creates unnecessary burden..."
    }
  ],
  "discussionPrompt": "What's your experience with certification renewals? Share your thoughts below.",
  "sourceArticles": [
    {
      "title": "New Certification Standards Proposed",
      "url": "https://example.com/article",
      "feedId": "feed-uuid"
    }
  ],
  "status": "pending",
  "generatedAt": "2025-01-15T08:00:00Z"
}
```

**Regularity Settings:**

```json theme={null}
{
  "debateFrequency": "weekly",
  "pollFrequency": "daily",
  "generationDay": "monday",
  "generationTime": "08:00",
  "timezone": "Australia/Sydney",
  "maxDebatesPerGeneration": 3,
  "maxPollsPerGeneration": 5,
  "autoApprove": false
}
```
