Flow designer variables to extract information from email body text

markdart
Kilo Guru

Hi I am trying to achieve from flow designer extracting information from the body text, Chatgpt helped with a script and I have tried some options with variables but not sure of the complete process as I keep getting blanks.

At this testing stage I am just trying to get it to output the HR Manager Name from the body of email to the Description Field

I think the first place I created the Variable and input the email body text into that seem correct but I feel I should be actually running that script after that and outputting that to the hrManager variable. 

 

ChatGPT script

// Assume the input text is passed as 'emailBody'
var emailBody = inputs.emailBody || '';
var hrManager = '';

// Use a regular expression to find the line starting with "HR Manager" and capture the value after it
var match = emailBody.match(/HR Manager\s+([^\n\r]+)/);

if (match && match[1]) {
    hrManager = match[1].trim();
}

outputs.hrManagerName = hrManager;
 
Actual email body text

ONBOARDING NOTIFICATION - IT REQUEST | NEW EMPLOYEE
________________________________
EMPLOYEE DETAILS
Resource Name
Person Name here
Preferred Name (If Applicable)

Location
QLD
Business Unit
Business Applications
Line Manager
Manager Name
HR Manager
Joe blog
Job Title
Operations Manager
Phone Number
99999999
Start Date
12/5/2025

ICT EQIUPMENT, SOFTWARE & ACCESS
Laptop Required
Yes
Which Office is the laptop been sent to?

If Laptop is not sent to office what is the address it is to be sent to

Does the laptop require a developers profile or admin account?
No
Do they require any other equipment?


IT Request - Software & Access
Required Distribution Lists

Required access to Department Folders/SharePoint sites

Access to customer accounts

Access to any other applications

OpenAir
Yes

Additional Notes

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@markdart 

check this link and enhance it further for your parsing logic

Easiest way to Trigger Catalog Item Request via Inbound Email 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@markdart 

check this link and enhance it further for your parsing logic

Easiest way to Trigger Catalog Item Request via Inbound Email 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader