Tutorials
Document AI Tutorials
Document Checklist
overview in this tutorial, we will see how cloudfiles can be used with salesforce flow automations to classify incoming documents and update the checklist appropriately each time a file is uploaded into salesforce or external storage, the following actions will occur the file is processed using cloudfiles document ai a natural language query executes to classify the uploaded files based on the classification, document checklist is updated in order to setup this automation, you first need to have some pre requisites after this you can start setting up some query automations and updates to achieve your use case check the sections below for more information this tutorial showcases how academic documents uploaded to a student's record in salesforce is classified using cloudfiles document ai based on the classification, the related document checklist (a child object) is updated with the document name, submission status, and upload date, ensuring automated tracking of student submissions pre requisites before starting with this tutorial, you need to ensure that cloudfiles document ai is properly installed & configured in your system additionally, you also need to create some initial automations to process the files before you can query them check the 2 sections below carefully installation & configuration ensure the following before starting cloudfiles document ai installation docid\ rfxciqrbejmpsmbczexam and configuration docid\ amnhmxwixyngnaxerbkwd are complete you have an active subscription or trial of cloudfiles document ai the cloudfiles event mode setting is set to custom object initial automation setup there are 2 flows you will need to setup to process the uploaded files the first flow is triggered when the document is uploaded into salesforce or external storage this flow sends the file to ai for processing this might take a few seconds once the ai is done with processing, the second flow will trigger which will contain the processed document you can then run queries on this processed document flow 1 send document for processing triggered when file is uploaded into salesforce or external storage sends the file for processing which may take a few seconds to a minute flow 2 document processing complete triggered when the file has been processed by ai performs queries on the file to extract the data read the article on ai flows initial setup guide docid\ sxn79rxu7gw7bb6ogpuix carefully to setup both the flows once your initial flows are setup as shown above, you are ready to move to the next step once your flow setup is complete, your flows should look like the following query automation setup now that you have the initial automation setup, we can take the document processed flow and extend it to query the document and update the required fields in this section, we show how to query the processed document, check the results and perform the necessary updates querying the document in order to query the document, we will simply use the query document docid\ dm3eh gzaocyoqd5y0r8d flow action this action takes a processed document id and a text query as input the processed document id is available as output of the get event details action here are the full inputs used in the image below processed document id ( {!get triggering event details documentprocessed processeddocumentid} ) query = enter a clear natural language classification prompt this prompt is used to classify academic documents uploaded to a student’s record in salesforce the goal is to identify the type of document and update the associated checklist accordingly classify the uploaded file into one of the following categories 10th marksheet, 12th marksheet, passport, transcript, or transfer certificate based on the document type identified, return a specific number as follows return 1 if the file is a 10th marksheet, 2 if it is a 12th marksheet, 3 for a passport, 4 for a transcript, and 5 for a transfer certificate if the document does not match any of these categories, return 0 only return the corresponding number with no additional explanation or text for example, if a 12th marksheet is uploaded , then the ai output will be 2 checking the answers the query document action above outputs a text variable which is the full response of ai for the given query you can use this text response with flow decision branches to perform relevant actions based on the document type below, we have used the response from ai to create 5 separate branches based on the document type, which we will use in the next step this step ensures the flow accurately identifies the type of document processed, allowing appropriate subsequent record updating actions updating document checklist once the classification result is received and matched using decision branches, the corresponding entry in the document checklist, a child object of the student record, can be filtered and updated each time a document is uploaded and processed, its status in the checklist is updated accordingly see it in action now that everything is set up, you can test your flows when a document is uploaded as a salesforce file on the record, the document checklist is automatically updated note as flow automation executions and document processing via ai may take a short time, the field updates will not reflect immediately to view the updates, wait briefly and refresh the page flow 2 debug whenever a file is processed using the process document using ai docid 31ujx1ligtkwfkjuanbzt action, a document processed docid\ xrr pnbpocwwcmyg6qgk9 object record is published you can query these event object records to verify successful file processing and debug the flow example soql query to check document processed events sorted by the most recent select id, name, createddate, cldfs data c from cldfs cloudfilesevent c where cldfs type c = 'document processed' order by createddate desc you can check the context and file details in the data field of the record when a flow runs in debug mode and executes query document docid\ dm3eh gzaocyoqd5y0r8d action, you can check the results and modify the queries if required