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 Gemini
gpt-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 incomplete
Cause: 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 AI
Cause: 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 undefined
Cause: 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
We can customize this sample to match your specific business requirements.
Book Free ConsultationThe 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.
This module is designed to visually showcase the features of a product or service by arranging images and text in an alternating layout. It uses scroll-triggered animations to engage users.
Learn how to implement a custom "Animated Counter" module in HubSpot to visually highlight your company's achievements and KPIs. This guide provides the complete HTML, CSS, JavaScript, and field configuration, allowing you to create a module that is intuitive even for non-developers.
This guide explains how to use "PhoneFormatter," a convenient Google Apps Script (GAS) library that allows you to batch-format international phone numbers in a Google Sheet. Easily convert numbers into their proper, hyphenated format simply by providing a country name in English, Japanese, or even abbreviated form.
Do you ever face the tedious task of managing address lists from various countries like Japan, the USA, and the UK in Google Sheets, wishing you could easily separate them by country, state, or city?
This article introduces "AddressParserLibrary," a Google Apps Script library that automates this data cleaning and parsing process with a single click.
Once you add the library, anyone can easily implement address parsing by making minor adjustments to the provided sample code. We will walk through everything from setup to execution in a step-by-step guide that is clear even for those unfamiliar with programming. Start boosting your daily productivity today!