EXPLORER

Mustafa AI Projects
Mustafa AI / Projects / AI / AI Powered Email Extraction And Case Matching Tool
AI + Salesforce

AI-Powered Email Extraction and Case Matching Tool

How I designed an intelligent Salesforce solution that extracts emails from unstructured text, matches contacts and related cases, and accelerates service response workflows using AI-assisted triage.

AI Email Extraction Tool

Overview

This project was designed to solve a common operational challenge: inbound emails and copied text often contain customer details buried inside unstructured content. Staff previously had to manually read the text, identify the sender, search for related contacts, and then check whether any existing cases were already open.

I designed an AI-powered Lightning Web Component that extracts email addresses from free text, automatically searches Salesforce contacts, retrieves related cases, and provides an AI-generated summary to help staff triage issues faster.

Key idea: reduce manual triage time by converting unstructured text into structured case intelligence.

The challenge

Support teams and service staff frequently receive copied emails, long text threads, and complaint descriptions pasted from Outlook or web forms.

The challenge was that critical information such as:

  • Customer email address
  • Contact details
  • Existing case history
  • Issue summary
  • Potential duplicate cases

had to be manually identified.

“The faster you can convert text into context, the faster your service teams can respond.”

Solution design

Step 1 — intelligent email extraction

The LWC scans pasted text and extracts email addresses using regex logic.

Step 2 — Salesforce contact matching

Once extracted, the component queries Contacts and related Cases using Apex.

Step 3 — AI-assisted summarisation

The raw email body is then passed to an AI summarisation layer that produces a concise issue summary for service officers.

Email extraction logic

public static List<String> extractEmails(String inputText) {
    Pattern pattern = Pattern.compile(
        '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}'
    );

    Matcher matcher = pattern.matcher(inputText);
    List<String> emails = new List<String>();

    while (matcher.find()) {
        emails.add(matcher.group());
    }

    return emails;
}

This extracted list is then used to search matching Contacts and related Cases.

Implementation example

Apex contact + case search

@AuraEnabled(cacheable=true)
public static List<Contact> searchContactsByEmail(String email) {
    return [
        SELECT Id, Name, Email,
            (SELECT Id, CaseNumber, Status FROM Cases ORDER BY CreatedDate DESC)
        FROM Contact
        WHERE Email = :email
        LIMIT 10
    ];
}

The result is displayed in a structured UI where staff can quickly open the matching contact or related case records.

This dramatically reduced the need to manually navigate across multiple objects.

Approach comparison

Approach Strength Trade-off
Manual triage Low technical setup High staff effort
Regex + Salesforce match Fast contact lookup Limited intelligence
AI-assisted triage Fast summary + context Requires governance

Project highlights

Smart email extraction

Extracts multiple emails from long text blocks automatically.

Contact & case matching

Finds related Salesforce contacts and existing cases instantly.

AI-powered summary

Converts long email chains into concise case-ready summaries.

Business impact

  • Reduced manual triage time
  • Improved duplicate case detection
  • Faster customer response
  • Improved case visibility
  • Introduced practical AI into service workflows

Want to build AI into business workflows?

I design AI-assisted Salesforce solutions that improve operational speed, decision-making, and customer service.

Contact Me

FAQ

Was this fully AI-driven?

The core matching logic was deterministic and integrated with AI summarisation for better triage and context.

What business problem did it solve?

It reduced the time service teams spent manually finding customer records and case history.