diff --git a/agents/configs/agents/lean-six-sigma-expert.json b/agents/configs/agents/lean-six-sigma-expert.json new file mode 100644 index 0000000..16af8e5 --- /dev/null +++ b/agents/configs/agents/lean-six-sigma-expert.json @@ -0,0 +1,16 @@ +{ + "slug": "lean-six-sigma-expert", + "name": "Lean Six Sigma Expert", + "short_description": "Get expert guidance on Lean Six Sigma methodologies and process improvement strategies", + "description": "Optimize your business processes with expert Lean Six Sigma consultation. Our AI-powered expert provides comprehensive guidance on process improvement, waste reduction, quality enhancement, and operational excellence. Get personalized recommendations for implementing Lean Six Sigma methodologies in your organization.", + "category": "consulting", + "price": 0.0, + "agent_type": "form", + "system_type": "direct_access", + "form_schema": { + "fields": [] + }, + "webhook_url": "https://agent.jotform.com/01987b8843ae71129342f62a93d2c605efad", + "access_url_name": "agents:direct_access_handler", + "display_url_name": "agents:direct_access_display" +} \ No newline at end of file diff --git a/agents/configs/categories/categories.json b/agents/configs/categories/categories.json index c3b3411..2047ec7 100644 --- a/agents/configs/categories/categories.json +++ b/agents/configs/categories/categories.json @@ -28,5 +28,11 @@ "name": "Marketing & Advertising", "description": "AI-powered marketing tools and advertising solutions", "icon": "📢" + }, + { + "slug": "consulting", + "name": "Business Consulting", + "description": "Professional business consultation and strategy services", + "icon": "💼" } ] \ No newline at end of file diff --git a/agents/management/commands/create_lean_six_sigma_agent.py b/agents/management/commands/create_lean_six_sigma_agent.py new file mode 100644 index 0000000..b7fdeba --- /dev/null +++ b/agents/management/commands/create_lean_six_sigma_agent.py @@ -0,0 +1,60 @@ +from django.core.management.base import BaseCommand +from agents.models import AgentCategory, Agent + +class Command(BaseCommand): + help = 'Create Lean Six Sigma Expert agent with JotForm integration' + + def handle(self, *args, **options): + # Create Business Consulting category + consulting_category, created = AgentCategory.objects.get_or_create( + slug='consulting', + defaults={ + 'name': 'Business Consulting', + 'description': 'Professional business consultation and strategy services', + 'icon': '💼' + } + ) + + if created: + self.stdout.write(self.style.SUCCESS(f'Created category: {consulting_category.name}')) + else: + self.stdout.write(f'Category already exists: {consulting_category.name}') + + # Create Lean Six Sigma Expert agent + lean_six_sigma_agent, created = Agent.objects.get_or_create( + slug='lean-six-sigma-expert', + defaults={ + 'name': 'Lean Six Sigma Expert', + 'short_description': 'Get expert guidance on Lean Six Sigma methodologies and process improvement strategies', + 'description': 'Optimize your business processes with expert Lean Six Sigma consultation. Our AI-powered expert provides comprehensive guidance on process improvement, waste reduction, quality enhancement, and operational excellence. Get personalized recommendations for implementing Lean Six Sigma methodologies in your organization.', + 'category': consulting_category, + 'price': 0.0, + 'agent_type': 'form', + 'form_schema': { + 'fields': [] # Empty since we're using JotForm directly + }, + 'webhook_url': 'https://agent.jotform.com/01987b8843ae71129342f62a93d2c605efad', + 'access_url_name': 'agents:direct_access_handler', + 'display_url_name': 'agents:direct_access_display' + } + ) + + if created: + self.stdout.write(self.style.SUCCESS(f'Created agent: {lean_six_sigma_agent.name}')) + self.stdout.write(f' 📝 Description: {lean_six_sigma_agent.short_description}') + self.stdout.write(f' 💰 Price: {lean_six_sigma_agent.price} AED') + self.stdout.write(f' 🔗 JotForm URL: {lean_six_sigma_agent.webhook_url}') + self.stdout.write(f' 📂 Category: {lean_six_sigma_agent.category.name}') + else: + self.stdout.write(f'Agent already exists: {lean_six_sigma_agent.name}') + + self.stdout.write('') + self.stdout.write(self.style.SUCCESS('✅ Lean Six Sigma Expert setup completed successfully')) + self.stdout.write('') + self.stdout.write('🚀 Next steps:') + self.stdout.write(' 1. Agent will appear in the Business Consulting category') + self.stdout.write(' 2. Users get free access to JotForm Lean Six Sigma consultation') + self.stdout.write(' 3. Visit /agents/lean-six-sigma-expert/ to test the interface') + self.stdout.write('') + self.stdout.write(f'Agent ID: {lean_six_sigma_agent.id}') + self.stdout.write(f'Agent Slug: {lean_six_sigma_agent.slug}') \ No newline at end of file diff --git a/agents/templates/agents/marketplace.html b/agents/templates/agents/marketplace.html index b9d7e03..05bb64c 100644 --- a/agents/templates/agents/marketplace.html +++ b/agents/templates/agents/marketplace.html @@ -82,6 +82,10 @@ Try Now → + {% elif agent.slug == 'lean-six-sigma-expert' %} + + Try Now → + {% else %} Try Now → {% endif %} @@ -94,6 +98,10 @@ 🔐 Login to Try + {% elif agent.slug == 'lean-six-sigma-expert' %} + + 🔐 Login to Try + {% else %} 🔐 Login to Try diff --git a/agents/urls.py b/agents/urls.py index eadd0dc..f82e418 100644 --- a/agents/urls.py +++ b/agents/urls.py @@ -12,6 +12,8 @@ urlpatterns = [ path('career-navigator/access/', views.career_navigator_access, name='career_navigator_access'), path('ai-brand-strategist/', views.ai_brand_strategist_view, name='ai_brand_strategist'), path('ai-brand-strategist/access/', views.ai_brand_strategist_access, name='ai_brand_strategist_access'), + path('lean-six-sigma-expert/', views.lean_six_sigma_expert_view, name='lean_six_sigma_expert'), + path('lean-six-sigma-expert/access/', views.lean_six_sigma_expert_access, name='lean_six_sigma_expert_access'), # API endpoints - specific URLs first to avoid slug conflicts path('api/execute/', views.execute_agent, name='execute_agent'), diff --git a/agents/views.py b/agents/views.py index 6860146..6845b18 100644 --- a/agents/views.py +++ b/agents/views.py @@ -1147,3 +1147,99 @@ def direct_access_display(request, slug): # For now, redirect directly to external form # Future: Can render iframe template or custom display logic return redirect(agent.webhook_url) + + +def lean_six_sigma_expert_view(request): + """Display the Lean Six Sigma Expert form page""" + if not request.user.is_authenticated: + # Clear all existing messages before adding login message + storage = messages.get_messages(request) + for _ in storage: + pass # Consume all messages + # Add login message to session for after login redirect + request.session['post_login_message'] = 'Please complete your login to access the Lean Six Sigma Expert.' + return redirect('authentication:login') + + # Get the Lean Six Sigma Expert agent + try: + agent = Agent.objects.get(slug='lean-six-sigma-expert', is_active=True) + except Agent.DoesNotExist: + messages.error(request, 'Lean Six Sigma Expert is currently unavailable.') + return redirect('agents:marketplace') + + # Check if user has a recent execution (within last 2 hours) or just redirect to payment + from django.utils import timezone + from datetime import timedelta + + recent_execution = AgentExecution.objects.filter( + agent=agent, + user=request.user, + status='completed', + created_at__gte=timezone.now() - timedelta(hours=2) + ).first() + + if not recent_execution: + messages.info(request, 'Please click "Try Now" to access your Lean Six Sigma Expert consultation.') + return redirect('agents:marketplace') + + context = { + 'agent': agent, + 'form_url': agent.webhook_url, + 'user_balance': request.user.wallet_balance, + 'execution': recent_execution + } + + return render(request, 'lean_six_sigma_expert.html', context) + + +def lean_six_sigma_expert_access(request): + """Handle Try Now button click - charge wallet and redirect to form""" + if not request.user.is_authenticated: + # Clear all existing messages before adding login message + storage = messages.get_messages(request) + for _ in storage: + pass # Consume all messages + # Add login message to session for after login redirect + request.session['post_login_message'] = 'Please complete your login to access the Lean Six Sigma Expert.' + return redirect('authentication:login') + + # Get the Lean Six Sigma Expert agent + try: + agent = Agent.objects.get(slug='lean-six-sigma-expert', is_active=True) + except Agent.DoesNotExist: + messages.error(request, 'Lean Six Sigma Expert is currently unavailable.') + return redirect('agents:marketplace') + + # Check if user has sufficient balance + if not request.user.has_sufficient_balance(agent.price): + messages.error(request, f'Insufficient balance! You need {agent.price} AED to access the Lean Six Sigma Expert.') + return redirect('wallet:wallet') + + # Deduct fee from user wallet + success = request.user.deduct_balance( + agent.price, + f'{agent.name} - Direct Access', + agent.slug + ) + + if not success: + messages.error(request, 'Failed to process payment. Please try again.') + return redirect('agents:marketplace') + + # Create execution record for tracking + execution = AgentExecution.objects.create( + agent=agent, + user=request.user, + input_data={'action': 'direct_access', 'source': 'try_now_button'}, + fee_charged=agent.price, + status='completed', + output_data={ + 'type': 'direct_access', + 'message': f'Direct access granted to {agent.name}', + 'access_method': 'try_now_button' + }, + completed_at=timezone.now() + ) + + # Redirect directly to form - no message needed + return redirect('agents:lean_six_sigma_expert') diff --git a/templates/lean_six_sigma_expert.html b/templates/lean_six_sigma_expert.html new file mode 100644 index 0000000..f7633cf --- /dev/null +++ b/templates/lean_six_sigma_expert.html @@ -0,0 +1,43 @@ +{% extends 'base.html' %} +{% load static %} + +{% block title %}Lean Six Sigma Expert - Quantum Tasks AI{% endblock %} + +{% block extra_css %} + +{% endblock %} + +{% block content %} +
+ +
+{% endblock %} \ No newline at end of file