AI Flows - Initial Setup Guide
This guide provides a detailed overview of setting up Salesforce flows to process files using CloudFiles Document AI. This setup is to be used as a pre-cursor to perform actual querying to get results from AI.
In order to ask a natural language query to CloudFiles AI, you first need to process the document and receive a processed document ID. The file to be processed can be either a Salesforce upload or it may be uploaded in external storages. CloudFiles provides functionlity to process both types of uploads, albeit in a slightly different manner.
Read the sections below carefully.
Ensure the following before starting:
- CloudFiles Installed in Salesforce: Available on Salesforce AppExchange.Check out Installation and Configuration and to know more.
- Active Subscription or Trial: Ensure access to CloudFiles Document AI
In order to query your files using AI, we first need to process the document. This prepares the document so that it can be sent to AI for querying.
You will need to create 2 separate flows. The first flow will trigger when the upload is done and will send the uploaded file to AI for processing. The second flow will trigger when the document has finished processing and can now be queried.
- Process New Document Flow - This flow sends any new file uploads for processing. Processing is an asynchronous operation and may take some time to complete.
- Document Processing Complete Flow - This flow executes when the document has been processed. This is the flow in which you will actually add the query & response logic.
To create these flows, first decide if you want to process a Salesforce file upload or an external storage file upload. Based on this, refer to one of the below articles in order to setup the flows.
For Salesforce File Uploads - If you are uploading files into the Salesforce Files or Notes & Attachments section, refer to Process Salesforce Files article in order to setup the initial flows.
For External Storage Uploads - If you are uploading files into external storages such as SharePoint or Google Drive, refer to Process External Files article in order to setup the initial flows.
Once you are finished with the relevant article, you should have the below two flows ready in your org. Here's a screenshot of how these flows will look like. Check the next section on how to use these flows further in order to get responses from AI.
When a new Salesforce File is uploaded or attached onto the records-

When a new file is uploaded in an external storage through the CloudFiles LWC-

First decide whether you want to work with Salesforce Files or External files and based on that, use either the Process Salesforce Files or the Process External Files article in order to setup the 2 flows.
Once you have the above flows setup, you are ready to start querying the document and getting responses. This is done using the 'Query Document' flow action. In order to see how this action can be used to achieve specific goals, refer to our detailed tutorials listed in the Document AI Tutorials article.
This tutorial only helps setup the initial flows to make the document ready for AI. In order to actually use AI to get responses, checkout other tutorials.
