---
schema_version: "1"
id: 7967382e7d213e95107dd8deb6c5d9236762320938606397f482b76ab3a5003a
title: Step 4 - Create Bank Statement Extraction Flow (Apex Wrapper)
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-ae/loan-agent/guides/aes-create-flow-bank-statement-extraction.md
canonical_url: https://developer.salesforce.com/docs/ai/loan-agent/guide/aes-create-flow-bank-statement-extraction.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: f211c09cbeb94e562365b63325230281c5b58da1541336e75ae9cadcac1c8174
products:
  - Loan Prequalification Agent
  - data-ae
---
# Step 4 - Create Bank Statement Extraction Flow (Apex Wrapper)

Create a screen flow to invoke your Apex method that extracts data from the customer’s bank statement.

## 1. Create a New Flow

On the **App Launcher**, create a new flow to extract data from the customer’s bank statement.

1. From the **App Launcher**, select **Flows**.
2. Click **New** to create a new flow.
3. Select the **Autolaunched Flow (No Trigger)** automation.

## 2. Add Your Apex Action to the Flow

1. In the Flow Builder, under **Autolaunched Flow**, click the **\+** button.
2. Select **Action**, and search for your Apex method under **Search Actions** on the right (Run Bank statement analysis using DataCloud Document AI).
3. Enter a flow label: `Bank_Statement_Extraction`.

## 3. Create Input Variables

1. Open the toolbox on the top left and click **New Resource** to create input variables.
2. The **New Resource** modal opens. Select Variable as **Resource Type**.
3. Enter `ContactEmail` as **API Name**.
4. Select Text as **Data Type**.
5. Check the checkbox next to **Available for input**.
6. Click **Done**.
7. Repeat steps 2-7 for these items:

   - `Org_Domain`
   - `Client_Id`
   - `Client_Secret`
   - `Document_Type`
   - `LLM_Model`
   - `ContentDocumentId`
   - `IDPConfigId`

## 4. Create Output Variables

1. Open the toolbox on the top left and click **New Resource** to create output variables.
2. In the **New Resource** modal, Select Variable as **Resource Type**.
3. Enter `Status` as **API Name**.
4. Select Text as **Data Type**.
5. Select **Available for output**.
6. Click **Done**.
7. Repeat steps 2-7 for these items:

   - `ExtractedDataJson`
   - `ErrorMessage`

## 5. Map Inputs and Store Outputs

1. Under **Set Input Values** on the right, enter these values to map the inputs.

   - Org_Domain → {\!Org_Domain}
   - Client_Id → {\!Client_Id}
   - Client_Secret → {\!Client_Secret}
   - Document_Type → {\!Document_Type}
   - LLM_Model → {\!LLM_Model}
   - ContentDocumentId → {\!ContentDocumentId}
   - IDPConfigId → {\!IDPConfigId}

![Input Mapping](https://developer.salesforce.com/docs/media/loan-agent-input-mapping.png '{"class": "image-framed"}')

2. Under **View Output Resources**, select **Manually assign variables (advanced)**.
3. Under **Store Output Values**, enter these values.

   - Status → {\!Status}
   - ExtractedDataJson → {\!ExtractedDataJson}
   - ErrorMessage → {\!ErrorMessage}

![Output Storing](https://developer.salesforce.com/docs/media/loan-agent-output-storing.png '{"class": "image-framed"}')

## 6. Save and Activate the Flow

1. Click the **Save** button, and save the flow as: `Bank_Statement_Extraction`.
2. On the saving modal, go to **Show Advanced**. Under **How to Run the Flow**, select **System Context Without Sharing–Access All Data**.
3. Click **Save**.
4. On the top right, click **Activate** to activate the flow.

## Next Step

- [Step 5 - Create the Loan Prequalification Employee Agent](https://developer.salesforce.com/docs/ai/loan-agent/guide/aes-create-loan-prequalification-agent.md): Build your loan prequalification agent.
