AI-Powered KYC Upload Checker
In this tutorial, we will see how CloudFiles can be used with Salesforce flow automations to create a KYC upload checker. Each time a file is uploaded into Salesforce or external storage, the following actions will occur :
- The file will be processed using CloudFiles Document AI.
- Natural Language Queries will execute to classify the file and extract key details.
- Corresponsing fields will be updated in Salesforce.
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. In the image below, we have demonstrated this in action.

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 -
Ensure the following before starting:
- You have an Active Subscription or Trial of CloudFiles Document AI.
- The CloudFiles Event Mode setting is set to Custom Object

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.
All information related to setting up these flows is given in the AI Flows - Initial Setup Guide article. Please go through this article carefully to set up these flows.
Once your flow setup is complete, your flows should look like the following.

Read the article on AI Flows - Initial Setup Guide carefully to setup both the flows. Once your initial flows are setup as shown above, you are ready to move to the next step.
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.
In order to classify the document, we will simply use the Query Document flow action along with a natural language prompt. 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 = Outputs from Get Event Details : Get Processed Event Details > Document Processed > ProcessedDocumentId
Query = Classify the file as either a driving license or a passport. If the file does not match either of these types, classify it as other. Based on the classification, give the output as one of the following - Driving License, Passport, or Other.

Now that our documents are classified, we can use the output of the 'Query Document' action to create 2 branches in our flow. In each of the branches, we will ask document specific questions to extract relevant information.
First, we will add a decision element to determine whether a document is a Driving License or a Passport based on the earlier classification query. We will create two outcomes for this decision element, one for each document type, as shown below -
and direct the flow accordingly. Then, we will add KYC-specific queries using the ‘Query Document’ action to retrieve crucial KYC details. Finally, we will populate these details into the relevant custom fields of the Account object. The detailed steps are given below -

Next, we will use more natural language queries to extract specific information from the documents. Different relevant queries can be written as text constants and applied as needed. It is advisable to make these queries highly objective and specific.
For this tutorial, we have used three queries: one to fetch the Passport number, another for the Passport country, and a third for the Driver's license number. Refer to the queries below for an understanding of prompt writing. You can customize these queries to suit your requirements.
Prompt to fetch Driver’s License Number - "Given document is a driving license. Extract the Driving License number from this and only output the driving license number. If Driving License number cannot be read, give output as Not Available."
Prompt to fetch Passport Country' - "Given document is a passport. Extract the Passport country from this and classify is as one of the following - USA, UK, Germany, Australia, India. If passport country cannot be classified as one of the given options then output Other."
Prompt to fetch Passport Number - "Given document is a passport. Extract the Passport number from this and only output the passport number. If passport number cannot be read, give output as Not Available."
The output of each of the queries will be used in next section to update the Salesforce fields.
We will use ‘Update Records’ action for updating the above fetched information in the relevant fields of the Account object record. Follow these configurations - Update Records > Check Specify conditions to identify records, and set fields individually > Fill Account as Object
Note - Here we are using earlier mentioned context of the uploaded file to find the right Account record by comparing Account ‘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 account records in ‘Update Records’.
Refer to the video given below for visual understanding -
Now that everything is setup, let’s test our flow. Follow the steps below to see this AI automation in action.
- Simply create a new Account record in Salesforce and then go the ‘Files’ tab that we added previously.
- Upload KYC document(s) using the ‘Files’ tab. You can upload the files one by one or multiple files at once. You can choose to upload passports, driver's licenses, or any other document types.
- The flow may take a few seconds to run so click on the refresh page on the top.
- Navigate to the ‘Details’ tab. You will find the relevant fields updated if the desired documents are uploaded, or the AI output will indicate if the Passport or Driver's License was not detected.

Congratulations! You've successfully created an AI-powered KYC Documents checker using CloudFiles AI & Salesforce flow.