Metadesign Solutions

Harnessing AI for Automated Candidate Data Extraction with Gemini AI API and Google App Script

Harnessing AI for Automated Candidate Data Extraction with Gemini AI API and Google App Script
  • Amit Gupta
  • 8 minutes read

Blog Description

Harnessing AI for Automated Candidate Data Extraction with Gemini AI API and Google App Script

Managing large volumes of candidate resumes manually can be a time-consuming and error-prone task, especially when extracting key information like contact details, skills, and work experience. To overcome this challenge, I developed an automated solution using Gemini AI API and Google App Script to efficiently process resumes from a Google Drive folder and extract vital candidate details into a structured Google Sheet.

Why This Automation Was Developed

The primary challenge was the need to quickly gather candidate information from hundreds of resumes stored in various formats (PDF, DOC, DOCX). Manually reviewing and extracting the data would have been a tedious and time-intensive task, prone to errors. We decided to leverage AI to automate this process, allowing for faster and more accurate extraction of:

  • Candidate names
  • Email addresses
  • Skills, tools, and technologies
  • Companies worked for
  • Experience summaries
  • LinkedIn profiles

This automation aimed to:

  • Save time: By reducing manual effort.
  • Improve accuracy: By letting AI handle complex text extraction.
  • Simplify candidate management: By creating a searchable, filterable database for future use.

How AI Simplified the Process

Traditional methods of data extraction often struggle with unstructured resume formats. However, by using the Gemini AI API, we relied on AI to intelligently extract structured data from resumes, no matter how complex the format. The AI not only pulled out essential details but also provided insights into each candidate’s skills and experience, allowing us to efficiently populate a database for future outreach.

Key Features of the Automation

  1. Resume Parsing: The script handles multiple file formats (PDF, DOC, DOCX) by converting them to Google Docs, extracting the text, and sending it to the Gemini AI API for analysis.
  2. Duplicate Detection: If a candidate’s email already exists in the database, the script automatically deletes the duplicate file from Google Drive.
  3. Data Structuring: All extracted information is neatly organized into a Google Sheet, making it easy to search, filter, and manage.
  4. Scalability: The system can process large datasets and multiple subfolders, making it suitable for extensive recruitment drives.

Important Code Fragments

Below are some key parts of the script used to automate this process. Sensitive details such as API keys and folder IDs have been hidden for security purposes.

  • Extracting Resume Text:

Javascript code:

				
					function extractTextFromFile(file) {
  const mimeType = file.getMimeType();

  // Handle Google Docs
  if (mimeType === 'application/vnd.google-apps.document') {
    const doc = DocumentApp.openById(file.getId());
    return doc.getBody().getText();
  }

  // Handle other document types
  if (['application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/msword', 'application/pdf'].includes(mimeType)) {
    return extractTextFromPDF(file);  // Custom function to convert PDF to text
  }

  return '';
}

				
			

Using Gemini AI for Data Extraction:

Javascript code:

				
					function fetchContentWithAI(prompt){
  const apiKey = 'YOUR_GEMINI_AI_API_KEY'; // Replace with your API key
  const url = `https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=${apiKey}`;
  const payload = { contents: [{ parts: [{ text: prompt }] }] };

  let result = 'N/A';
  try {
    const response = UrlFetchApp.fetch(url, {
      payload: JSON.stringify(payload),
      contentType: 'application/json',
    });
    const obj = JSON.parse(response.getContentText());
    result = obj.candidates[0].content.parts[0].text;  // Extract AI-generated content
  } catch (error) {
    Logger.log('Error:', error.message);
  }

  return result;
}

				
			

Duplicate Email Detection:

Javascript code: 
				
					function isEmailDuplicate(email, sheet) {
  const emailColumn = sheet.getRange(2, 4, sheet.getLastRow() - 1, 1).getValues().flat();
  return emailColumn.includes(email);
}

function processFile(file, sheet, processedFilesSheet) {
  const txt = extractTextFromFile(file);
  const dataStr = fetchContentWithAI(`Extract details: ${txt}`);

  const email = fetchPartsFromSummary(dataStr, 'Email Address');
  if (isEmailDuplicate(email, sheet)) {
    file.setTrashed(true);  // Remove duplicate file
    return;
  }

  // Append data to Google Sheet
  sheet.appendRow([/* Insert extracted data into sheet */]);
}

				
			

Benefits of Using AI for Resume Processing

By automating the resume extraction process, we reduced the manual workload and achieved the following key benefits:

  • Increased speed: Hundreds of resumes were processed in minutes.
  • Improved accuracy: The AI consistently and accurately identified and extracted critical data.
  • Scalable solution: The automation can handle large datasets, making it ideal for recruitment campaigns or large applicant pools.

With AI handling most of the data extraction, we now have a structured database of candidates that can be easily filtered and searched based on specific criteria such as skills or experience, allowing for targeted candidate outreach.

What is Google Apps Script and How It Helps Automate Business Workflows

Google Apps Script is a cloud-based scripting language that allows you to automate tasks and workflows across Google’s suite of products, such as Google Sheets, Google Drive, Gmail, and more. It’s based on JavaScript, making it easy to pick up for anyone familiar with the language. Google Apps Script provides a powerful platform to create custom functions, automate repetitive tasks, and even build custom applications that integrate with Google Workspace products.

Why Use Google Apps Script for Workflow Automation?

  1. Seamless Integration with Google Workspace: Apps Script integrates natively with Google Workspace (G Suite), including Google Sheets, Drive, Gmail, Calendar, and Docs. You can automate routine tasks, such as data entry, file management, sending automated emails, and even processing complex workflows, all within the Google ecosystem.

  2. Cloud-Based: Since Apps Script is cloud-based, it runs directly in your browser and requires no setup, servers, or additional infrastructure. This makes it incredibly easy to deploy automation scripts that can run across different Google services without worrying about maintenance.

  3. Customizable and Extensible: With Apps Script, you can create custom functions and workflows tailored to your specific business needs. From manipulating data in spreadsheets to creating approval workflows or building custom dashboards, the possibilities are endless.

  4. Cost-Effective: Since Apps Script is free with a Google account, it’s a cost-effective solution for businesses looking to automate repetitive tasks without investing in expensive third-party tools or custom development.

  5. Efficient Automation: Google Apps Script can handle a wide variety of tasks, from simple automation like email notifications to complex processes like managing large datasets across multiple spreadsheets or integrating with external APIs.

Benefits of Using Google Apps Script for Automating Business Workflows

  1. Increased Productivity: By automating repetitive tasks, businesses can significantly reduce manual work, enabling employees to focus on more strategic initiatives.

  2. Improved Accuracy: Automation helps eliminate human error, ensuring that tasks are performed consistently and accurately every time.

  3. Streamlined Processes: With automation, workflows become faster and more efficient. Tasks like sending follow-up emails, updating spreadsheets, or generating reports can be triggered automatically without manual intervention.

  4. Scalability: Google Apps Script allows you to scale your workflows effortlessly. Whether you’re managing a few documents or handling thousands of records across multiple spreadsheets, Apps Script can handle the load.

  5. Easy to Learn and Implement: Since Google Apps Script is based on JavaScript, it’s relatively easy to learn, especially for developers familiar with web development. Even non-developers can quickly grasp the basics to create useful automations for their business.

Example Use Cases for Google Apps Script

  • Automated Reporting: Automatically generate weekly or monthly reports from Google Sheets and email them to team members.
  • File Management: Automatically organize files in Google Drive, rename them, and set access permissions based on custom logic.
  • Email Notifications: Send automated email reminders based on calendar events or changes in Google Sheets.
  • Approval Workflows: Create custom approval processes where documents move between folders or users based on status changes in Google Sheets.

Get the Code

If you’re interested in automating your own resume processing with this method or using Google Apps Script for other workflows, feel free to reach out to us! For more information or to get the full script, please email us at sales@metadesignsolutions.com. We’d be happy to help you set it up!

This solution has proven to be a time-saver and game-changer for managing candidate data, and we’d love to share it with you.

0 0 votes
Blog Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top

GET a QUOTE

Contact Us for your project estimation
We keep all information confidential and automatically agree to NDA.