Tutorials
Document AI Tutorials
Signature Checking
overview in this tutorial, we will see how cloudfiles can be used with salesforce flow automations to check if a document is signed and authenticated 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 runs to detect the presence of a signature the related salesforce record is updated to reflect whether the signature is present or not 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 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 taken in 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 such as check if a valid signature from a doctor is present in the given document a valid signature may be handwritten or digital and is typically located near the bottom or in a designated section of the document it may also be accompanied by identifying information such as the doctor’s name, designation, or license number return 'yes' if a valid signature from a doctor is present, otherwise return 'no' example suppose a medical prescription, as shown below, is uploaded to the files section of the corresponding record to verify the authenticity of the document, we use the following query "check if the document contains a valid doctor's signature return 'yes' if a valid signature is present; otherwise, return 'no' " this query helps determine whether the document is verified based on the presence of a valid signature the ai output for this document is 'yes' check ai output and update the record the query document action returns text variables as the ai's response to the input query if the response is yes , indicating the document is verified, proceed to identify the correct patient record record to do this, compare the ‘ id ’ with the ‘ context’ in order to do so use id equals outputs from get processed event details > documentprocessed > context field value pair to filter contact records in ‘ update records ’ see it in action now that everything is set up, you can test your flows when a medical form or prescription is uploaded into a medical form record, the verfied status is updated if a valid signature is present 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 actions, you can check the results and modify the queries if required