Skip to content

Task Manager Lite - Intelligent Task Routing System#

Running the Application#

  1. Start the backend server:

    jac serve task_manager.jac
    
    The API server will be available at http://localhost:8000
  2. Launch the frontend (in a new terminal window):

    jac streamlit frontend.jac
    
    The web interface will be accessible at http://localhost:8501

Usage Examples#

Task Management Operationsk Manager Lite is a lightweight AI-powered task management system that intelligently routes user requests to specialized handlers for task management, email writing, and general conversation.

Features#

Intelligent Routing#

  • Automatically determines the best handler for your request
  • Routes to specialized nodes: TaskHandling, EmailHandling, or GeneralChat
  • Uses AI-powered classification for accurate routing

Task Management#

  • Add Tasks: Create tasks with dates and times
  • Task Summarization: Get summaries of all scheduled tasks
  • Smart Extraction: Automatically extracts task details from natural language

Email Writing#

  • Generate professional emails for various purposes
  • Context-aware email content creation
  • Support for different email types (meetings, follow-ups, etc.)

General Chat#

  • Ask questions and get intelligent responses
  • Get advice on productivity and time management
  • General AI assistance for various topics

Architecture#

Nodes#

  • TaskHandling: Manages task creation, scheduling, and summarization
  • EmailHandling: Handles email content generation
  • GeneralChat: Provides general AI conversation capabilities

Walker#

  • task_manager: Main walker that routes requests and coordinates responses

Complete Code Preview#

Here's what you'll build - an intelligent task routing system in just two files:

Task Manager Lite Frontend

import from byllm.llm { Model }

glob llm = Model(model_name="gpt-4o");

node Task {
    has task:str = "";
    has date:str = "";
    has time:str = "";
}

node TaskHandling {
    def add_task(task: Task) -> str {
        self ++> task;
        return "Task added successfully";
    }
    def check_scheduled_tasks -> list[Task] {
        self ++> Task(
            task="Check scheduled tasks",
            date="2025-10-10",
            time="10:00:00"
        ); # Add a sample task for demonstration
        return [self --> (`?Task)];
    }
    def extract_task_info(utterance: str) -> str by llm(
        method="ReAct",
        tools=([self.add_task])
    );
    def summarize_tasks() -> str by llm(
        method="ReAct",
        tools=([self.check_scheduled_tasks])
    );
    def route_and_run(utterance: str) -> str by llm(
        method="ReAct",
        tools=([self.extract_task_info, self.summarize_tasks])
    );
    can execute with task_manager entry {
        print("[TaskHandling Node Activated]");
        response = self.route_and_run(visitor.utterance);
        print("→", response);
        visitor.response = response;
        visitor.node_type = "TaskHandling";
    }
}

node EmailHandling {
    def write_email_content(utterance: str) -> str by llm();
    def route_and_run(utterance: str) -> str by llm(
        method="ReAct",
        tools=([self.write_email_content])
    );
    can execute with task_manager entry {
        print("[EmailHandling Node Activated]");
        response = self.route_and_run(visitor.utterance);
        print("→", response);
        visitor.response = response;
        visitor.node_type = "EmailHandling";
    }
}

node GeneralChat {
    def chat(utterance: str) -> str by llm();
    can execute with task_manager entry {
        print("[GeneralChat Node Activated]");
        response = self.chat(visitor.utterance);
        print("→", response);
        visitor.response = response;
        visitor.node_type = "GeneralChat";
    }
}

enum RoutingNodes{
    TASK_HANDLING,
    EMAIL_HANDLING,
    GENERAL_CHAT
}

walker task_manager {
    has utterance: str = "";
    has response: str = "";
    has node_type: str = "";

    def route_to_node(utterance: str) -> RoutingNodes by llm();
    can execute with `root entry {
        routed_node_name = self.route_to_node(self.utterance);

        if routed_node_name == RoutingNodes.TASK_HANDLING {
            routed_node = here ++> TaskHandling();
        } elif routed_node_name == RoutingNodes.EMAIL_HANDLING {
            routed_node = here ++> EmailHandling();
        } elif routed_node_name == RoutingNodes.GENERAL_CHAT {
            routed_node = here ++> GeneralChat();
        }
        visit routed_node;

        # Report results for frontend
        report {
            "utterance": self.utterance,
            "response": self.response,
            "node_type": self.node_type,
            "routed_to": str(routed_node_name)
        };
    }
}
import streamlit as st;
import requests;

def bootstrap_frontend(token: str) {
    st.set_page_config(
        page_title="Task Manager Lite - AI Assistant",
        page_icon="📋",
        layout="wide"
    );

    st.title("📋 Task Manager Lite - AI Assistant");
    st.markdown("✨ Intelligent task management, email writing, and general chat");

    # Initialize session state
    if "task_results" not in st.session_state {
        st.session_state.task_results = [];
    }
    if "loading" not in st.session_state {
        st.session_state.loading = False;
    }

    # Main interface
    st.markdown("### 💭 What can I help you with today?");

    # Examples
    with st.expander("💫 Example Requests") {
        st.markdown("**📋 Task Management**");
        if st.button("➕ Add a task") {
            st.session_state.user_input = "Add a task to buy groceries tomorrow at 3 PM";
        }
        if st.button("📝 Summarize tasks") {
            st.session_state.user_input = "Summarize all my tasks";
        }

        st.markdown("**📧 Email Writing**");
        if st.button("✉️ Write a meeting email") {
            st.session_state.user_input = "Write an email to schedule a meeting with my team for next Friday";
        }
        if st.button("📬 Write follow-up email") {
            st.session_state.user_input = "Write a follow-up email for the project update";
        }

        st.markdown("**💬 General Chat**");
        if st.button("🤔 Ask a question") {
            st.session_state.user_input = "What are the best practices for time management?";
        }
        if st.button("🌟 Get advice") {
            st.session_state.user_input = "How can I be more productive at work?";
        }
    }

    # Text input
    user_input = st.text_area(
        "💬 Enter your request:",
        value=st.session_state.get("user_input", ""),
        height=100,
        placeholder="e.g., Add a task to review the presentation by 5 PM tomorrow 📊"
    );

    # Process button
    if st.button("🚀 Process Request") {
        if user_input.strip() {
            st.session_state.loading = True;
            st.rerun();
        } else {
            st.warning("⚠️ Please enter a request!");
        }
    }

    # Show loading state
    if st.session_state.loading {
        with st.spinner("🧠 AI is processing your request...") {
            try {
                response = requests.post(
                    "http://localhost:8000/walker/task_manager",
                    json={"utterance": user_input},
                    headers={"Authorization": f"Bearer {token}"}
                );

                if response.status_code == 200 {
                    result = response.json();
                    task_result = result.get("reports", [{}])[0];

                    # Add to results history
                    st.session_state.task_results.insert(0, task_result);

                    # Keep only last 10 results
                    if len(st.session_state.task_results) > 10 {
                        st.session_state.task_results = st.session_state.task_results[:10];
                    }

                    st.session_state.loading = False;
                    st.success("✅ Request processed successfully!");
                    st.rerun();
                } else {
                    st.error(f"❌ Processing failed: {response.text}");
                    st.session_state.loading = False;
                }
            } except requests.exceptions.Timeout {
                st.error("⏰ Request timed out. Please try again.");
                st.session_state.loading = False;
            } except Exception as e {
                st.error(f"❌ Error: {str(e)}");
                st.session_state.loading = False;
            }
        }
    }

    # Display results
    if st.session_state.task_results {
        st.markdown("---");
        st.markdown("## 📊 Recent Activity");

        i = 0;
        for result in st.session_state.task_results {
            # Determine node type icon and color
            node_type = result.get("node_type", "Unknown");
            routed_to = result.get("routed_to", "");

            if node_type == "TaskHandling" {
                icon = "📋";
                color = "blue";
            } elif node_type == "EmailHandling" {
                icon = "📧";
                color = "green";
            } elif node_type == "GeneralChat" {
                icon = "💬";
                color = "orange";
            } else {
                icon = "🤖";
                color = "gray";
            }

            with st.expander(f"{icon} {node_type} - Request {i+1}") {
                # Request details
                st.markdown(f"**🔀 Routed to:** `{routed_to}`");

                # User input
                st.markdown("**👤 Your Request:**");
                st.info(result.get("utterance", "No input recorded"));

                # AI response
                st.markdown("**🤖 AI Response:**");
                response_text = result.get("response", "No response recorded");
                if response_text {
                    if node_type == "TaskHandling" {
                        st.success(response_text);
                    } elif node_type == "EmailHandling" {
                        st.success(response_text);
                    } else {
                        st.info(response_text);
                    }
                } else {
                    st.warning("No response available");
                }

                # Copy response button
                if st.button(f"📋 Copy Response {i+1}") {
                    st.write("📋 Response copied to clipboard! (Use Ctrl+C to copy manually)");
                }
            }
            i += 1;
        }

        # Clear history button
        if st.button("🗑️ Clear History") {
            st.session_state.task_results = [];
            st.session_state.user_input = "";
            st.rerun();
        }
    }

    # Sidebar with information
    with st.sidebar {
        st.markdown("## 🎯 Features");
        st.markdown("""
        **📋 Task Management**
        - Add new tasks with dates/times
        - View and summarize tasks
        - Intelligent task extraction

        **📧 Email Assistant**
        - Generate professional emails
        - Context-aware content
        - Various email types

        **💬 General Chat**
        - Ask questions
        - Get advice and tips
        - General assistance
        """);

        st.markdown("---");
        st.markdown("**🧠 AI Routing**");
        st.markdown("Your requests are automatically routed to the most appropriate handler for optimal results.");
    }

    # Footer
    st.markdown("---");
    st.markdown("**🤖 Powered by Task Manager Lite AI Assistant**");
    st.markdown("✨ Features: 📋 Task management • 📧 Email writing • 💬 Smart chat • 🔀 Intelligent routing");
}


with entry {
    INSTANCE_URL = "http://localhost:8000";
    TEST_USER_EMAIL = "test@mail.com";
    TEST_USER_PASSWORD = "password";

    response = requests.post(
        f"{INSTANCE_URL}/user/login",
        json={"email": TEST_USER_EMAIL, "password": TEST_USER_PASSWORD}
    );

    if response.status_code != 200 {
        # Try registering the user if login fails
        response = requests.post(
            f"{INSTANCE_URL}/user/register",
            json={
                "email": TEST_USER_EMAIL,
                "password": TEST_USER_PASSWORD
            }
        );
        assert response.status_code == 201;

        response = requests.post(
            f"{INSTANCE_URL}/user/login",
            json={"email": TEST_USER_EMAIL, "password": TEST_USER_PASSWORD}
        );
        assert response.status_code == 200;
    }

    token = response.json()["token"];

    bootstrap_frontend(token);
}

Usage#

  1. Install dependencies:

    pip install jac-streamlit requests jaclang jac-cloud byllm
    
  2. Start the Jac Cloud server:

    jac serve task_manager.jac
    
  3. Run the frontend:

    jac streamlit frontend.jac
    

Task Management#

  • "Add a task to buy groceries tomorrow at 3 PM"
  • "Schedule a meeting with the team for Friday at 10 AM"
  • "Summarize all my tasks"

Email Writing#

  • "Write an email to schedule a meeting with my team"
  • "Create a follow-up email for the project update"
  • "Write a professional email to request a deadline extension"

General Chat#

  • "What are the best practices for time management?"
  • "How can I be more productive at work?"
  • "What was the most popular programming language in 2020?"

Requirements#

  • Python 3.8+
  • JAC (Jaseci Action Circuit)
  • Streamlit (for frontend)
  • OpenAI API key (for GPT-4)

Configuration#

The system uses GPT-4 by default. You can modify the model in task_manager.jac:

glob llm = Model(model_name="gpt-4o");

Looking for the full version? This is a lite version for learning purposes. Check out the full-scale Task Manager project for a complete implementation with advanced features.

File Structure#

  1. Install required dependencies:
    pip install jac-streamlit jaclang datetime byllm jac-cloud
    

Running the Application#

  1. Start the backend server:

    jac serve task_manager.jac
    
    The API server will be available at http://localhost:8000
  2. Launch the frontend interface:

    jac streamlit frontend.jac
    
    The web interface will be accessible at http://localhost:8501

Usage Examples#

Task Management Operations#

Creating Tasks:

"Schedule a team meeting with the development team next Tuesday at 2 PM"
"Remind me to call the client about the project update tomorrow morning"
"Add a deadline for the quarterly report submission on March 15th"

Task Queries:

"What do I have scheduled for next week?"
"Show me all my high-priority tasks"
"Summarize my meetings for this month"

Email Generation#

Meeting Invitations:

"Write an email inviting the team to a project kickoff meeting"
"Create a follow-up email for the client presentation yesterday"

Professional Communications:

"Draft an email updating stakeholders on project progress"
"Write a professional response declining a meeting request"

General Chat and Assistance#

Productivity Questions:

"What are some effective time management strategies for remote work?"
"How can I better organize my daily tasks?"
"What's the best way to handle multiple project deadlines?"

Information Requests:

"Explain the Pomodoro technique"
"What are common productivity tools for teams?"

Technical Deep Dive#

Task Extraction Algorithm#

Natural language processing extracts structured task information:

obj Task {
    has title: str;
    has description: str;
    has due_date: str;
    has priority: str;
    has status: str;
    has assignee: str;
}

Email Template System#

Dynamic email generation based on context and purpose:

obj EmailTemplate {
    has subject: str;
    has greeting: str;
    has body: str;
    has closing: str;
    has tone: str; # formal, casual, urgent
}

Advanced Features#

Smart Scheduling#

  • Conflict Detection: Identifies scheduling conflicts automatically
  • Optimal Time Suggestions: Proposes best meeting times based on availability
  • Calendar Integration: Syncs with external calendar systems
  • Timezone Handling: Manages tasks across different time zones

Task Dependencies#

  • Prerequisite Tracking: Manages task dependencies and ordering
  • Automatic Prioritization: Adjusts task priorities based on dependencies
  • Progress Monitoring: Tracks completion of dependent tasks
  • Bottleneck Identification: Highlights tasks blocking project progress

Email Context Integration#

  • Task-Aware Emails: Incorporates relevant task information in emails
  • Meeting Summaries: Generates emails with meeting outcomes and action items
  • Status Updates: Creates progress reports based on task completion
  • Reminder Emails: Automated follow-ups for upcoming deadlines

Learning and Adaptation#

  • User Pattern Recognition: Learns from user preferences and habits
  • Improved Routing: Enhances intent classification over time
  • Personalized Responses: Adapts communication style to user preferences
  • Context Memory: Maintains long-term conversation context

Future Integration Improvements#

Calendar Systems#

  • Google Calendar: Sync tasks and events with Google Calendar
  • Outlook Integration: Connect with Microsoft Outlook and Exchange
  • Calendar APIs: Support for various calendar service APIs
  • ICS Export: Generate standard calendar files for import

Communication Platforms#

  • Slack Integration: Send task updates and reminders via Slack
  • Microsoft Teams: Integrate with Teams for collaborative task management
  • Email Services: Connect with SMTP servers for automated email sending
  • Notification Systems: Push notifications for task deadlines and updates

Project Management Tools#

  • Jira Sync: Synchronize with Jira for software development projects
  • Trello Integration: Connect with Trello boards and cards
  • Asana Compatibility: Import and export tasks to Asana projects
  • Custom APIs: Flexible integration with proprietary systems

Performance Optimization#

Scalability Features#

  • Async Processing: Handle multiple requests concurrently
  • Caching Systems: Cache frequent responses and classifications
  • Load Balancing: Distribute requests across multiple handler instances
  • Database Optimization: Efficient storage and retrieval of tasks and emails

Response Time Optimization#

  • Predictive Loading: Pre-load common responses and templates
  • Smart Caching: Cache personalized responses for frequent users
  • Batch Processing: Handle multiple similar requests efficiently
  • Resource Management: Optimal allocation of computational resources

Security and Privacy#

Data Protection#

  • Encryption: Secure storage of tasks and personal information
  • Access Control: Role-based permissions for multi-user environments
  • Audit Logging: Track all system interactions and modifications
  • Data Anonymization: Protect sensitive information in logs and analytics

Authentication and Authorization#

  • User Authentication: Secure login and session management
  • API Security: Token-based authentication for API access
  • Permission Management: Fine-grained control over feature access
  • Single Sign-On: Integration with enterprise authentication systems

Monitoring and Analytics#

Usage Analytics#

  • Request Patterns: Analysis of common user requests and intents
  • Handler Performance: Metrics on routing accuracy and response quality
  • User Satisfaction: Feedback collection and satisfaction measurement
  • System Health: Monitoring of system performance and availability

Improvement Metrics#

  • Classification Accuracy: Intent recognition success rates
  • Response Quality: User ratings of generated content
  • Task Completion Rates: Success metrics for task management features
  • User Engagement: Metrics on user interaction and retention

Task Manager Lite demonstrates the power of intelligent routing and specialized handling in agentic AI systems, showing how different capabilities can be combined to create comprehensive and effective task management solutions.