Extracting data from attachments

Not applicable

Hi All,
There is use case where user will attach an attachment that may be doc or pdf or png or excel or csv etc. Attachment will be on the incident form, Now we have to extract all the data which is in that attachments, How do we extract data in the attachment?

10 REPLIES 10

Hi @Community Alums 

 

Make use of below REST message body and retry :

{
    "contents": [
        {
            "parts": [
                {
                    "text": "You are a very professional document summarization specialist.
Please summarize the given document."
                },
                {
                    "inline_data": {
                        "mime_type": "image/jpeg", // Change it based on image type
                        "data": "${imageBase64}" // Pass Base64 string of the image here
                    }
                }
            ]
        }
    ]
}

 

Thanks and Regards

Amit Verma

Thanks and Regards
Amit Verma

vermaamit16
Kilo Patron

Hi @Community Alums 

 

If I understood your requirement clearly, you want to read the content of the attachments on an incident record. If yes, please note that not all the attachment types could be parsed within ServiceNow directly, for example, you can't get the .png file content until you make use of external LLMs like Gemini. If you wish to make use of external LLM, the approach would be to first convert the attachment into Base64 string and send it to the model for analysis.

 

If you just want to parse CSV files, please refer https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/CSVParserScoped/concept/CSVParserScopedAPI.html

 

Thanks and Regards

Amit Verma

Thanks and Regards
Amit Verma

Ankur Bawiskar
Tera Patron

@Community Alums 

what you want to do after getting the content? you want to send to some 3rd party API?

What's your exact business requirement?

You can get base64Encoded data of the file but not direct content

within ServiceNow you can only read plain attachments such as (txt, csv, excel) etc.

You cannot read data from DOC, PDF, DOCX, PPT, PNG etc as they are complex file type.

For others you can use CSVParser or GlideExcelParser

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

@Community Alums 

Hope you are doing good.

Did my reply answer your question?

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

Not applicable

Hi @Ankur Bawiskar ,
We need to send the content which is in the attachment to the AZURE AI, We are trying to send the attachment directly to the AZURE AI to get the summary of the attachment.