Step 5 - Create Flow Elements

Create the Flow Builder elements to set the actions that the flow executes.

  1. On the flow you created in Step 4 - Create the Screen Flow, click the + button, search and select the Get Records element.
  2. Configure the Get Records element:
    • Label: Get Current Contact Record
    • Data Source: Salesforce Object
    • Object: Contact
    • Filter Contact Records:
      • Field: Contact ID
      • Operator: Equals
      • Value: +New Resource:
      • Resource Type: Variable
      • API Name: recordId
      • Data Type: Text
      • Under Availability Outside the Flow, select Available for input and Available for output.
      • Click Done.
  3. Click Save to save the Get Records element.
  4. Name your flow (for example, Document AI Flow for Resumes).
  5. Click Save to save the element.
  1. After the Get Current Contact Record element, click the + button, search and select the Get Records element.
  2. Configure the Get Content Document Link Record element:
    • Label: Get Content Document Link Record
    • Data Source: Salesforce Object
    • Object: Content Document Link
    • Filter Content Document Link Records:
      • Field: LinkedEntityId
      • Operator: Equals
      • Value: recordId
    • Sort Order: Descending
    • Sort By: SystemModstamp
    • How Many Records to Store: Only the first record
    • How to Store Record Data: Choose fields and assign variables (advanced)
    • Select Variable to Store Content Document Link Fields:
      • Record: +New Resource
      • Resource Type: Variable
      • API Name: ContentDocId
      • Data Type: Text
      • Under Availability Outside the Flow, select Available for input and Available for output.
      • Click Done.
    • Where to Store Field Values: In separate variables.
    • Select Variables to Store Content Document Link Fields:
      • Field: ContentDocumentId
      • Variable: ContentDocId
  3. Click Save to save this element.
  1. After the Get Content Document Link Record element, click the + button, search and select Get Records.
  2. Configure the Get Content Document Name element:
    • Label: Get Content Document Name
    • Data Source: Salesforce Object
    • Object: ContentDocument
    • Filter Content Document Records:
      • Field: ContentDocumentId
      • Operator: Equals
      • Value: ContentDocId
    • How Many Records to Store: Only the first record
    • How to Store Record Data: Choose fields and assign variables (advanced)
    • Select Variable to Store Content Document:
      • Record: + New Resource
      • Resource Type: Variable
      • API Name: fileName
      • Data Type: Text
      • Under Availability Outside the Flow, select Available for input and Available for output.
      • Click Done.
    • Where to Store Field Values: In separate variables.
    • Select Variables to Store Content Document Fields:
      • Field: Title
      • Variable: fileName
  3. Click Save to save this element.

This action invokes the Document AI Apex action you created in Step 3 - Create Apex Classes.

  1. After the Get Content Document Name element, click the + button, search and select Action.
  2. Search and select the Apex class you created: de_DataCloudIDPFlowAction.
  3. Give the action a descriptive label (for example, Document AI Apex Action).
  4. Set the input parameters:
  5. Click Save to save this element.

Enrich from File Action

This action invokes the prompt template you created in Step 2 - Create a Prompt Template in Prompt Builder.

  1. After the Document AI Apex Action element, click the + button, search and select Action.
  2. Search and select the second Apex class you created in Step 3 - Create Apex Classes: de_ExtractDocumentAIDetails.
  3. Configure the action:
    • Label: Handle JSON Output
    • Set Input Values:
    • Document AI JSON or Raw Data: Select the output from the previous Apex action (Outputs from Document AI Apex Action) and then select Extracted Data (JSON).
    • Prompt Template API Name: Enter the ID of the prompt template you created in # Step 2 - Create a Prompt Template in Prompt Builder.
  4. Set the input parameters:
    • Document AI JSON and Raw Data: Output from the previously defined Apex action (element 4).
    • Prompt template API Name: The ID from the prompt template created in Create a New Prompt Template.
  5. Click Save to save this element.

Enrich from File Action

With this flow element, you can review and edit the extracted data before it updates the Contact record.

  1. After the Handle JSON Output element, click the + button, find and select Screen.

  2. Select Screen.

  3. In the Components tab, find and select Text.

  4. In the Properties tab, set the component label, for example: First Name.

  5. Under Default Value find and select the corresponding Apex value from the second Apex class you created: Extract Resume Details with Document AI. For example: Outputs from Handle_JSON_Outout > First_name.

  6. Click Finish.

  7. Repeat steps 3-5 for each component.

    LabelMap to Apex value
    First Name(from Apex output)
    Last Name(from Apex output)
    Email Address(from Apex output)
    Phone Number(from Apex output)
    Street Address(from Apex output)
    City(from Apex output)
    State or Province(from Apex output)
    Country(from Apex output)
    Pin Code or Zip Code(from Apex output)
    Summary of Qualifications(from Apex output)
  8. After you have on your screen a text field for each of these items, click Done.

Enrich from File Action

  1. After the Screen** element, click the + button.

  2. Find and select Update Records.

  3. Configure the element:

    • Label: Update Contact Record
    • How to Find Records to Update: Specify conditions to identify records, and set fields individually
    • Object: Contact
    • Filter Contact Records:
      • Field: Contact ID
      • Operator: Equals
      • Value: recordId
    • Set Field Values for the Contact Record: Map each field in the table to the corresponding output from the Screen element. For example: For Mailing City Select Raw Output from Document AI > City.
    Contact FieldScreen / Source Value
    MailingCityCity
    MailingStateState or Province
    MailingCountryCountry
    MailingStreetStreet Address
    MailingPostalCodePin Code or Zip Code
    DescriptionSummary of Qualifications
    EmailEmail Address
    MobilePhonePhone Number
  4. Click Save to save the element.

  5. Click Activate to make the flow available for use.

Loan Agent on Sales Cloud