# Step 5 - Create Flow Elements

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

## 1. Create a Flow Element to Get Current Contact Record

1. On the flow you created in [Step 4 - Create the Screen Flow](/docs/ai/automate-resume-processing/guide/aes-create-screen-flow.md), 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.

## 2. Create a Flow Element to Get Content Document Link Record

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.

## 3. Create a Flow Element to Get Content Document Name

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.

## 4. Create a Flow Element to Add the Document AI Apex Action

This action invokes the Document AI Apex action you created in [Step 3 - Create Apex Classes](/docs/ai/automate-resume-processing/guide/aes-create-apex-classes.md).

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:
   - **Client ID:** Your consumer key from [Prerequisite 1 - Create and Configure an External Client App](/docs/ai/automate-resume-processing/guide/aes-create-external-client-app.md).
   - **Client Secret:** Your client secret from [Prerequisite 1 - Create and Configure an External Client App](/docs/ai/automate-resume-processing/guide/aes-create-external-client-app.md).
   - **Content Document ID:** `ContentDocId`
   - **Document Type:** `application/pdf` (default)
   - **Enter Org Domain:** Your domain URL with the `https://` prefix from [Prerequisite 2 - Retrieve Your Salesforce Domain URL](/docs/ai/automate-resume-processing/guide/aes-retrieve-sf-domain-url.md).
   - **IDP Config:** Ensure it's toggled to **included** and enter `resume_config` (or the API name you used in [Step 1: Create a Document AI Configuration to Process Resumes](/docs/ai/automate-resume-processing/guide/aes-create-document-ai-schema-config.md)).
5. Click **Save** to save this element.

![Enrich from File Action](https://a.sfdcstatic.com/developer-website/sfdocs/data-ae/media/resume-document-ai-apex-action.png)

## 5. Create a Flow Element to Handle JSON Output

This action invokes the prompt template you created in [Step 2 - Create a Prompt Template in Prompt Builder](/docs/ai/automate-resume-processing/guide/aes-create-prompt-template.md).

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](/docs/ai/automate-resume-processing/guide/aes-create-apex-classes.md): **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](/docs/ai/automate-resume-processing/guide/aes-create-prompt-template.md).
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](/docs/ai/automate-resume-processing/guide/aes-create-prompt-template.md).
5. Click **Save** to save this element.

![Enrich from File Action](https://a.sfdcstatic.com/developer-website/sfdocs/data-ae/media/resume-handle-json-output.png)

## 6. Create a Flow Element to Display Extracted Data

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](/docs/ai/automate-resume-processing/guide/aes-create-apex-classes.md). For example: **Outputs from Handle_JSON_Outout** > **First_name**.

6. Click **Finish**.

7. Repeat steps 3-5 for each component.

   | Label                     | Map 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](https://a.sfdcstatic.com/developer-website/sfdocs/data-ae/media/resume-screen-fields.png)

## 7. Create a Flow Element to Update Contact Record

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 Field     | Screen / Source Value     |
   | ----------------- | ------------------------- |
   | MailingCity       | City                      |
   | MailingState      | State or Province         |
   | MailingCountry    | Country                   |
   | MailingStreet     | Street Address            |
   | MailingPostalCode | Pin Code or Zip Code      |
   | Description       | Summary of Qualifications |
   | Email             | Email Address             |
   | MobilePhone       | Phone Number              |

4. Click **Save** to save the element.

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

![Loan Agent on Sales Cloud](https://a.sfdcstatic.com/developer-website/sfdocs/data-ae/media/resume-update-contact-record-element.png)

## Next Step

- [Step 6 - Add the Flow as a Quick Action Button on Contact Page](/docs/ai/automate-resume-processing/guide/aes-add-quick-action-button.md) — Add the Enrich from File button to the Contact page and test.
