Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

HR Employees Template

The HR Employees template provides a comprehensive employee management system that helps HR teams manage employee records, organizational structure, and personnel information through a conversational interface.

Topic: Employee Management & HR Directory

This template is perfect for:

  • HR departments
  • People operations teams
  • Employee self-service portals
  • Organizational management
  • Employee directory services

The Code

ADD TOOL "add-employee"
ADD TOOL "update-employee"
ADD TOOL "search-employee"
ADD TOOL "employee-directory"
ADD TOOL "org-chart"
ADD TOOL "emergency-contacts"

USE KB "employees.gbkb"

SET CONTEXT "employee management" AS "You are an HR assistant helping manage employee information. Help with adding new employees, updating records, searching the directory, viewing org charts, and managing emergency contacts. Maintain confidentiality of employee data."

CLEAR SUGGESTIONS

ADD SUGGESTION "directory" AS "Employee directory"
ADD SUGGESTION "add" AS "Add new employee"
ADD SUGGESTION "search" AS "Search employee"
ADD SUGGESTION "org" AS "Organization chart"
ADD SUGGESTION "emergency" AS "Emergency contacts"

BEGIN TALK
**Employee Management System**

I can help you with:
• View employee directory
• Add new employees
• Search for employees
• View organization chart
• Manage emergency contacts
• Generate employee reports

Select an option or tell me what you need.
END TALK

BEGIN SYSTEM PROMPT
You are an HR assistant for the Employee Management System.

Confirm sensitive operations before executing.
Never expose salaries or personal IDs without authorization.
Use professional and helpful language.
END SYSTEM PROMPT

Sample Dialogs

These conversations show how the HR Employees template works in real-world scenarios.

Dialog 1: Search Employee

Dialog 2: Add New Employee

Dialog 3: View Organization Chart

Dialog 4: Emergency Contacts

Keywords Used

KeywordPurpose
ADD TOOLRegister employee management tools
USE KBLoad HR knowledge base
SET CONTEXTDefine HR assistant behavior
ADD SUGGESTIONCreate quick action buttons
BEGIN TALKWelcome message block
BEGIN SYSTEM PROMPTConfidentiality and behavior rules

Template Structure

employees.gbai/
├── employees.gbdialog/
│   ├── start.bas              # Main entry point
│   ├── add-employee.bas       # New employee onboarding
│   ├── update-employee.bas    # Update employee records
│   ├── search-employee.bas    # Employee search
│   ├── employee-directory.bas # Full directory view
│   ├── org-chart.bas          # Organization structure
│   └── emergency-contacts.bas # Emergency contact access
├── employees.gbdata/
│   └── employees.csv          # Employee database
├── employees.gbdrive/
│   └── templates/             # Document templates
├── employees.gbkb/
│   ├── hr-policies.md         # HR policies
│   └── org-structure.md       # Organization info
└── employees.gbot/
    └── config.csv             # Bot configuration

Search Employee Tool: search-employee.bas

PARAM query AS STRING LIKE "John" DESCRIPTION "Name, department, or title to search for"
PARAM department AS STRING LIKE "Engineering" DESCRIPTION "Filter by department" OPTIONAL

DESCRIPTION "Search for employees by name, department, or title"

' Build search filter
filter = "name LIKE '%" + query + "%' OR title LIKE '%" + query + "%'"

IF department THEN
    filter = "(" + filter + ") AND department = '" + department + "'"
END IF

' Execute search
results = FIND "employees.csv", filter

IF UBOUND(results) = 0 THEN
    TALK "No employees found matching '" + query + "'"
    RETURN NULL
END IF

TALK "🔍 Found " + UBOUND(results) + " employee(s):"
TALK ""

FOR EACH emp IN results
    TALK "**" + emp.name + "**"
    TALK "📧 " + emp.email
    TALK "📞 Ext. " + emp.extension
    TALK "💼 " + emp.title
    TALK "🏢 " + emp.department
    TALK ""
NEXT

RETURN results

Add Employee Tool: add-employee.bas

PARAM name AS STRING LIKE "John Smith" DESCRIPTION "Employee full name"
PARAM title AS STRING LIKE "Software Engineer" DESCRIPTION "Job title"
PARAM department AS STRING LIKE "Engineering" DESCRIPTION "Department name"
PARAM manager AS STRING LIKE "Jane Doe" DESCRIPTION "Manager's name"
PARAM start_date AS DATE LIKE "2025-02-01" DESCRIPTION "Start date"

DESCRIPTION "Add a new employee to the system"

' Generate employee ID
employeeId = "EMP-" + FORMAT(NOW(), "YYYY") + "-" + FORMAT(RANDOM(1000, 9999))

' Generate email
emailName = LOWER(REPLACE(name, " ", "."))
email = emailName + "@company.com"

' Assign extension
extension = FORMAT(RANDOM(4000, 4999))

' Find manager ID
managerRecord = FIND "employees.csv", "name = '" + manager + "'"
IF NOT managerRecord THEN
    TALK "⚠️ Manager '" + manager + "' not found. Please verify the name."
    RETURN NULL
END IF

' Create employee record
WITH employee
    id = employeeId
    name = name
    email = email
    extension = extension
    title = title
    department = department
    manager_id = managerRecord.id
    manager_name = manager
    start_date = start_date
    status = "active"
    created_at = NOW()
END WITH

' Save to database
SAVE "employees.csv", employee

' Send welcome email
SEND MAIL email, "Welcome to the Company!", 
    "Dear " + name + ",\n\n" +
    "Welcome to the team! Your employee ID is " + employeeId + ".\n" +
    "Your manager is " + manager + ".\n" +
    "Start date: " + FORMAT(start_date, "MMMM DD, YYYY") + "\n\n" +
    "HR will contact you with onboarding details.\n\n" +
    "Best regards,\nHR Team"

' Create IT ticket for equipment
CREATE_TASK "New Employee Setup - " + name, 
    "Please prepare workstation for new employee:\n" +
    "Name: " + name + "\n" +
    "Department: " + department + "\n" +
    "Start Date: " + FORMAT(start_date, "MMM DD, YYYY"),
    "it@company.com"

' Notify manager
SEND MAIL managerRecord.email, "New Team Member: " + name,
    "A new team member has been added:\n\n" +
    "Name: " + name + "\n" +
    "Title: " + title + "\n" +
    "Start Date: " + FORMAT(start_date, "MMM DD, YYYY") + "\n\n" +
    "Please prepare for their onboarding."

TALK "✅ Employee **" + name + "** added successfully!"
TALK "🆔 ID: " + employeeId
TALK "📧 Email: " + email
TALK "📞 Extension: " + extension

RETURN employee

Org Chart Tool: org-chart.bas

PARAM department AS STRING LIKE "Engineering" DESCRIPTION "Department to show org chart for"
PARAM manager AS STRING DESCRIPTION "Show org chart under specific manager" OPTIONAL

DESCRIPTION "Display organization chart for a department or team"

IF manager THEN
    ' Get org chart under specific manager
    managerRecord = FIND "employees.csv", "name = '" + manager + "'"
    IF NOT managerRecord THEN
        TALK "Manager not found."
        RETURN NULL
    END IF
    
    reports = FIND "employees.csv", "manager_id = '" + managerRecord.id + "'"
    
    TALK "👔 **" + manager + "** - " + managerRecord.title
    FOR EACH emp IN reports
        subReports = COUNT("employees.csv", "manager_id = '" + emp.id + "'")
        IF subReports > 0 THEN
            TALK "├── 👤 " + emp.name + " (" + emp.title + " - " + subReports + " reports)"
        ELSE
            TALK "├── 👤 " + emp.name + " (" + emp.title + ")"
        END IF
    NEXT
ELSE
    ' Get department org chart
    deptHead = FIND "employees.csv", "department = '" + department + "' AND title LIKE '%Director%' OR title LIKE '%VP%'"
    
    IF NOT deptHead THEN
        deptHead = FIND "employees.csv", "department = '" + department + "' AND title LIKE '%Manager%'"
    END IF
    
    TALK "🏢 **" + department + " Organization**"
    TALK ""
    
    FOR EACH head IN deptHead
        TALK "👔 **" + head.title + "** - " + head.name
        
        reports = FIND "employees.csv", "manager_id = '" + head.id + "'"
        FOR EACH emp IN reports
            subCount = COUNT("employees.csv", "manager_id = '" + emp.id + "'")
            IF subCount > 0 THEN
                TALK "├── 👤 " + emp.name + " (" + subCount + " reports)"
            ELSE
                TALK "├── 👤 " + emp.name
            END IF
        NEXT
        TALK ""
    NEXT
END IF

totalCount = COUNT("employees.csv", "department = '" + department + "'")
TALK "**Total:** " + totalCount + " employees in " + department

RETURN department

Customization Ideas

Add Employee Self-Service

' Allow employees to update their own info
IF user_id = employee.id THEN
    TALK "What would you like to update?"
    ADD SUGGESTION "phone" AS "Phone number"
    ADD SUGGESTION "address" AS "Address"
    ADD SUGGESTION "emergency" AS "Emergency contacts"
    ADD SUGGESTION "photo" AS "Profile photo"
    
    HEAR updateChoice
    
    ' Only allow non-sensitive updates
    IF updateChoice = "phone" THEN
        TALK "Enter your new phone number:"
        HEAR newPhone
        UPDATE "employees.csv" SET phone = newPhone WHERE id = user_id
        TALK "✅ Phone number updated!"
    END IF
END IF

Add Birthday Reminders

' Scheduled job for birthday notifications
SET SCHEDULE "0 9 * * *"  ' Run daily at 9 AM

today = FORMAT(NOW(), "MM-DD")
birthdays = FIND "employees.csv", "FORMAT(birth_date, 'MM-DD') = '" + today + "'"

FOR EACH emp IN birthdays
    ' Notify their team
    manager = FIND "employees.csv", "id = '" + emp.manager_id + "'"
    SEND MAIL manager.email, "🎂 Team Birthday Today!", 
        emp.name + " has a birthday today! Don't forget to wish them well."
    
    ' Send birthday message
    SEND MAIL emp.email, "🎂 Happy Birthday!", 
        "Dear " + emp.name + ",\n\nHappy Birthday from all of us!"
NEXT

Add Anniversary Tracking

' Check for work anniversaries
today = FORMAT(NOW(), "MM-DD")
anniversaries = FIND "employees.csv", "FORMAT(start_date, 'MM-DD') = '" + today + "'"

FOR EACH emp IN anniversaries
    years = YEAR(NOW()) - YEAR(emp.start_date)
    IF years > 0 THEN
        SEND MAIL emp.email, "🎉 Happy Work Anniversary!",
            "Congratulations on " + years + " years with us!"
        
        ' Milestone recognition
        IF years = 5 OR years = 10 OR years = 15 OR years = 20 THEN
            CREATE_TASK "Milestone Recognition - " + emp.name,
                emp.name + " has completed " + years + " years. Please arrange recognition.",
                "hr@company.com"
        END IF
    END IF
NEXT

Add Department Reports

ADD TOOL "department-report"

PARAM department AS STRING DESCRIPTION "Department to generate report for"

DESCRIPTION "Generate a department headcount and demographics report"

employees = FIND "employees.csv", "department = '" + department + "'"

totalCount = UBOUND(employees)
managerCount = 0
avgTenure = 0

FOR EACH emp IN employees
    IF INSTR(emp.title, "Manager") > 0 OR INSTR(emp.title, "Director") > 0 THEN
        managerCount = managerCount + 1
    END IF
    avgTenure = avgTenure + DATEDIFF(NOW(), emp.start_date, "years")
NEXT

avgTenure = avgTenure / totalCount

TALK "📊 **" + department + " Department Report**"
TALK ""
TALK "👥 Total Employees: " + totalCount
TALK "👔 Managers: " + managerCount
TALK "📅 Avg. Tenure: " + FORMAT(avgTenure, "#.#") + " years"
TALK ""
TALK "**By Level:**"
' ... additional breakdown

Data Security

The employee management system includes several security features:

  1. Access Control: Sensitive data requires authorization
  2. Audit Logging: All access to confidential info is logged
  3. Data Masking: Personal IDs and salaries are not exposed
  4. Emergency Override: Emergency contacts accessible with justification