
The Department Classification Library is an AI-powered automatic classification tool that runs in the Google Apps Script environment. It uses ChatGPT or Gemini to automatically classify company department names into predefined business segments.


The Department Classification Library is an AI-powered automatic classification tool that runs in the Google Apps Script environment. It uses ChatGPT or Gemini to automatically classify company department names into predefined business segments.
Add the library to your Google Apps Script project:
Library ID: [YOUR_LIBRARY_ID_HERE]
Identifier: DeptClassifier
javascript
function setup( ) {
DeptClassifier.setupSheets();
}Configure the following in the Configuration sheet:
ChatGPT or Geminigpt-4, gemini-pro, etc.javascriptfunction classify() {
DeptClassifier.classifyDepartments();
}

setupSheets()Executes initial setup and creates necessary sheets.
javascript
DeptClassifier.setupSheets();
Created Sheets:
Department Data: Department names and classification resultsSegment Definitions: Classification category definitionsConfiguration: AI API settingsclassifyDepartments()Main classification execution function.
javascript
DeptClassifier.classifyDepartments();
Process:
classifyDepartmentsSafe()Safe classification execution considering API quota limits.
javascript
DeptClassifier.classifyDepartmentsSafe();
Features:
classifyDepartmentsCustom(departments, config)Execute classification with custom settings.
Parameters:
departments (Array): Array of department names to classifyconfig (Object): Custom configuration objectjavascript
const customConfig = {
aiProvider: 'ChatGPT',
model: 'gpt-4',
apiKey: 'your-api-key',
segments: [
{ name: 'Sales', description:
'Sales-related departments'
},
{
name: 'Tech', description: 'Technology-related departments'
}
]};
const results = DeptClassifier.classifyDepartmentsCustom( ['Sales Department', 'Engineering Team'], customConfig
);
retryFailedClassifications()Retry failed classifications.
javascript
DeptClassifier.retryFailedClassifications();
manualClassifyDepartments(departmentNames, segmentNames)Execute manual classification.
javascript
DeptClassifier.manualClassifyDepartments(
['Partner Sales Division', 'Business Planning Office'],
['Partner Sales', 'Sales Planning/PMM']
);

javascript//
1. Setup
function initializeLibrary() { DeptClassifier.setupSheets(); console.log('Setup completed');}
// 2. Run classification
function runClassification() { try { DeptClassifier.classifyDepartments(); console.log('Classification completed'); } catch (error) { console.error('Error:', error.message); }}
// 3. Check results
function checkResults() { // Manually check sheet contents}
javascript
function processLargeDataset() {
// Safe classification execution
DeptClassifier.classifyDepartmentsSafe();
// Retry failed items
Utilities.sleep(60000); // Wait 1 minute
DeptClassifier.retryFailedClassifications();
}
javascript
function customWorkflow() {
// 1. Custom segments for tech companies
const techSegments = [
{ name: 'Frontend', description: 'Frontend development' },
{ name: 'Backend', description: 'Backend development' },
{ name: 'DevOps', description: 'Infrastructure & operations' },
{ name: 'Product', description: 'Product management' },
{ name: 'Sales', description: 'Sales & business development' } ];
// 2. Classify with custom configuration
const departments = [
'Frontend Development',
'Backend Engineering',
'SRE Team',
'Product Manager',
'Sales Division' ];
const config = {
aiProvider: 'ChatGPT',
model: 'gpt-4',
apiKey: 'your-openai-key',
segments: techSegments };
const results = DeptClassifier.classifyDepartmentsCustom(departments, config);
console.log('Custom classification results:', results);}
Configuration incompleteCause: Incomplete Configuration sheet settingsSolution:
javascript
// Check configuration
DeptClassifier.testConfiguration();
API quota exceeded (429 error)Cause: API quota limit exceededSolution:
javascript
// Execute in safe mode
DeptClassifier.classifyDepartmentsSafe();// Or switch to different API// Change AI Provider in Configuration sheet
Invalid response from AICause: Unexpected response from AI APISolution:
javascript
// Execute retry
DeptClassifier.retryFailedClassifications();// Or manual classification
DeptClassifier.manualClassifyDepartments(
['Problematic department name'],
['Appropriate segment name']
);
Cannot read properties of undefinedCause: API response structure issuesSolution:
javascript
// Configuration test
function debugConfiguration() {
const isValid = DeptClassifier.testConfiguration();
if (!isValid) {
console.log('Please check configuration');
}
}// Small sample test
function debugClassification() {
try {
const results = DeptClassifier.testSingleClassification();
console.log('Test successful:', results);
} catch (error) {
console.error('Test failed:', error.message);
}
}
Cost estimate for classifying 100 departments:
Please report bugs via GitHub Issues:
Features under consideration:
MIT License - Commercial use allowed
Version: 1.2.0
Last Updated: September 2025
No, the position on the smartphone (mobile view) is fixed. According to the "Positioning Notes" in this article, while you can choose the horizontal alignment ("left/center/right") for the text block on the desktop view, the mobile view defaults to a standard position (e.g., center-aligned) to prioritize readability.
Yes, you can. The "What you can do" section mentions this, and the "Field setting examples" list includes show_cta_bubble (a boolean field to toggle the note's visibility) and cta_text (a text field to enter the note's content).
The "Field setting examples" list in this article does not include any style-related fields like color pickers or font size (number) inputs. Therefore, with this module's standard configuration, you likely cannot change these from the editor interface, and modifying the design would probably require CSS knowledge.The "Field setting examples" list in this article does not include any style-related fields like color pickers or font size (number) inputs. Therefore, with this module's standard configuration, you likely cannot change these from the editor interface, and modifying the design would probably require CSS knowledge.
We can customize this sample to match your specific business requirements.
Book Free Consultation