← Documentation Home

AI Agentic Workflows Module

Government-compliant agentic workflow system with FedRAMP/FISMA security controls, NIST 800-53 implementation, and OWASP-compliant API endpoints.

Overview

The AI Agentic Workflows module provides enterprise-grade AI-powered workflow orchestration for Drupal, enabling complex multi-step workflows with visual builders, ECA integration, and government-level security compliance.

Module Information

Source Location

/Users/flux423/Sites/LLM/all_drupal_custom/modules/ai_agentic_workflows/

Features

Core Capabilities

Security Features

AI & Machine Learning

Installation

Via Composer

composer require bluefly/ai_agentic_workflows:^1.0
drush en ai_agentic_workflows -y
drush updb -y
drush cr

Post-Installation

# Import configuration
drush config:import -y

# Initialize sample workflows
drush ai-workflow:install-samples

# Configure AI provider
drush cset ai.provider.openai.settings api_key "your-api-key" -y

Dependencies

Required Modules

Suggested Modules

Configuration

Basic Settings

Navigate to: /admin/config/workflow/agentic

# config/ai_agentic_workflows.settings.yml
workflow_engine: 'eca'
default_timeout: 300
max_workflow_steps: 20
enable_caching: true
cache_duration: 1800

Content Moderation

# config/ai_agentic_workflows.settings.yml
content_moderation:
  enable_ai_moderation: true
  sentiment_threshold: 0.3
  toxicity_threshold: 0.8
  quality_threshold: 0.6
  auto_publish_threshold: 0.2
  flag_threshold: 0.5

Security Configuration

# config/ai_agentic_workflows.security.yml
security:
  rate_limiting:
    enabled: true
    max_executions_per_hour: 50
    window: 3600
  input_validation:
    max_context_size: 524288
    dangerous_patterns:
      - 'javascript:'
      - 'data:text/html'
      - 'vbscript:'
  audit_logging:
    enabled: true
    retention_days: 90

Usage

Creating a Workflow

Via UI

  1. Navigate to /admin/config/workflow/agentic/flows/add
  2. Configure:
  3. Label: Human-readable name
  4. Description: Purpose and functionality
  5. Event: Trigger event
  6. Action: AI action to perform
  7. Provider: AI provider
  8. Save workflow

Via Code

<?php

use Drupal\ai_agentic_workflows\Entity\AgenticFlow;

$flow = AgenticFlow::create([
  'id' => 'custom_content_analyzer',
  'label' => 'Custom Content Analyzer',
  'description' => 'Analyzes content for quality and completeness',
  'status' => TRUE,
  'event' => 'content_save',
  'action' => 'analyze_content',
  'provider' => 'openai',
  'workflow_steps' => [
    [
      'id' => 'analyze',
      'label' => 'Analyze Content',
      'agent_type' => 'content_analyzer',
      'parameters' => [
        'analysis_depth' => 'comprehensive',
        'check_seo' => TRUE,
      ],
    ],
  ],
]);
$flow->save();

Via Drush

# Create from template
drush ai-workflow:create content_enhancement --template=content_processing

# List templates
drush ai-workflow:templates

# Custom workflow
drush ai-workflow:create my_workflow \
  --label="My Custom Workflow" \
  --event=content_save \
  --action=analyze_content \
  --provider=openai

Executing Workflows

Programmatically

<?php

// Load workflow
$flow = \Drupal::entityTypeManager()
  ->getStorage('agentic_flow')
  ->load('content_moderation');

// Execute
$executor = \Drupal::service('ai_agentic_workflows.flow_executor');
$result = $executor->executeFlow($flow, [
  'node_id' => 123,
  'prompt' => 'Analyze this content for quality',
]);

if ($result['success']) {
  $analysis = $result['result'];
}

Via REST API

curl -X POST https://example.com/api/v1/agentic-workflows/execute \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "flow_id": "content_moderation",
    "context": {
      "node_id": 123
    }
  }'

Via Drush

# Execute workflow
drush ai-workflow:execute content_moderation --context='{"node_id": 123}'

# Execute all enabled
drush ai-workflow:execute-all

# List executions
drush ai-workflow:list-executions --flow=content_moderation

API Documentation

REST Endpoints

List Workflows

GET /api/v1/agentic-workflows

Execute Workflow

POST /api/v1/agentic-workflows/execute
Content-Type: application/json

{
  "flow_id": "content_moderation",
  "context": {
    "node_id": 123
  }
}

Response

{
  "success": true,
  "result": {
    "toxicity_score": 0.1,
    "sentiment": "positive",
    "quality_score": 0.85
  },
  "execution_id": "abc123"
}

GraphQL API

query {
  agenticWorkflows(status: ENABLED) {
    id
    label
    description
    executions(limit: 10) {
      id
      status
      created
      result
    }
  }
}

OpenAPI Documentation

Hooks

hook_ai_agentic_workflows_flow_config_alter()

Modify flow configuration before creation.

<?php

function mymodule_ai_agentic_workflows_flow_config_alter(array &$config, string $flow_id) {
  $config['context']['my_data'] = my_module_get_data();
}

hook_ai_agentic_workflows_flow_executed()

React to flow execution completion.

<?php

function mymodule_ai_agentic_workflows_flow_executed(array $result, $flow, array $context) {
  if ($result['success']) {
    my_module_process_result($result);
  }
}

Security & Compliance

FedRAMP Compliance

Implements FedRAMP Moderate security controls:

NIST 800-53 Controls

Troubleshooting

No AI providers available

composer require drupal/ai_provider_openai
drush en ai_provider_openai -y
drush cset ai.provider.openai.settings api_key "your-key" -y

Rate limit exceeded

drush cache:clear
drush cset ai_agentic_workflows.settings rate_limit_max 100 -y

Workflow timeout

// In settings.php
$config['ai_agentic_workflows.settings']['default_timeout'] = 600;
$config['ai_agentic_workflows.settings']['queue_processing'] = TRUE;

Testing

# Run tests
vendor/bin/phpunit modules/custom/ai_agentic_workflows/tests

# Check coding standards
buildkit drupal phpcs modules/custom/ai_agentic_workflows --fix

# Validate design
buildkit drupal taste modules/custom/ai_agentic_workflows

Resources

See Also