# Build agent with pre trained knowledge

# Tutorials

This section is for new users and provides a practical, step-by-step walkthrough to build your first complete workflow.

# Getting Started: Build an Invoice Processing Workflow

In this guide, you'll learn how to create an Automated Workflow that retrieves invoice files from an S3 bucket, classifies each file using an Agent, and extracts relevant data from documents identified as invoices. The goal is to help you build, test, and publish a complete automation pipeline in just a few minutes.

In this tutorial, you'll learn how to:

  • Create and configure a new workflow from scratch.

  • Use an S3 connector to retrieve files from cloud storage.

  • Process a list of items using a Loop.

  • Implement conditional logic with an If/Else component.

Prerequisites:

  • You have a pre-built and published Automation Agent capable of classifying documents.

  • You have a pre-built and published Automation Agent capable of extracting data from invoices.

Step 1: Create the Automated Workflow Agent

First, you'll create the foundation for your workflow's logic and configurations. This agent will act as the container for all the components and steps in your process.

  1. Navigate to the Expert Agent Studio module.

  2. Click the + Build button in the top-right corner.

  3. In the What would you like to create? dialog, select Automated Workflow.

  4. In the Solution Details section, provide the following:

    • Name: Invoice_Workflow

    • Description: Extract and classify incoming invoices from S3

    • Visibility: Private

  5. Click Create to launch the canvas and begin designing your workflow.

Step 2: Configure the Start Node

Next, you'll define how the workflow is triggered. This is the mandatory first step that determines how your process begins.

  1. Click the Start node on the canvas.

  2. Under How Should This Workflow Start?, choose Manual or API Trigger.

  3. In the Input Variables section, define the following input:

    • Input Name: Input_Path

    • Data Type: Text

This input defines the folder path in the S3 bucket that the workflow will monitor.

Step 3: Declare Environment Variable for S3 Bucket

Before adding the S3 connector, you'll define an environment variable for the bucket name. This makes the bucket reference reusable across your workflow and ensures it's correctly picked up during execution.

  1. Navigate to the top header and click the Settings icon.

  2. In the Environment Variables section:

    • Click + Add Variable.

    • Label: Bucket_Name

    • Value: finance-invoices-bucket (replace with your actual bucket name)

This variable will now be available for use in the S3 component configuration.

Step 4: Add an AWS S3 Download Connector

Now, you'll connect the workflow to Amazon S3 to retrieve the invoice files. This component handles the interaction with the external cloud storage service.

  1. Click the + button after the Start node.

  2. Select AWS S3 and set the Operation to Download.

  3. In the Configuration Panel, set the following:

    • Connection: Choose a valid connection (e.g., S3_Finance_Connector).

    • Bucket Name: Select the Bucket_Name environment variable.

    • Path: Map to Input_Path (defined in the Start node).

Step 5: Add a Loop to Process Each File

Because the S3 connector can return multiple files, a loop is needed to perform the same set of actions on each one individually.

  1. Click the + button after the AWS S3 Download component.

  2. Select the Loop component.

  3. In the Configuration Panel, configure the following:

    • Input Variable: Select AWS S3 → files.

    • On Error Action: Choose Continue on Error.

    • This ensures that if one file fails to process, the loop will still proceed to the next file.

Step 6: Add a Classification Agent Inside the Loop

You'll use an Agent to determine whether each document is an invoice. Placing this component inside the loop ensures it runs for every file retrieved from S3.

  1. Inside the Loop, click the + button.

  2. Select the Invoice Classifier agent.

  3. In the Configuration Panel, map the agent's input:

    • Input (Invoice): Map to Loop → item.

    • This ensures that each file is passed to the agent one at a time.

Step 7: Add Conditional Logic to Handle Invoices

Next, you'll branch the flow with an If/Else component. This allows your workflow to make a decision and take different actions based on the classification result.

  1. Add an If/Else component after the classification agent.

  2. In the Configuration Panel, set the Condition: Invoice Classifier → Document_type equals invoice.

  3. In the True (If) branch (this path runs if the condition is met):

    • Add the Invoice Extraction agent.

    • Input: Map to Loop → item

    • This agent performs structured extraction from documents confirmed as invoices.

  4. In the False (Else) branch (this path runs if the document is not an invoice):

Step 8: Test and Publish the Workflow

Finally, you'll validate the workflow to ensure correctness before publishing. Testing is a critical step to catch errors before the workflow is live.

  1. Click Test in the top header.

  2. If your workflow uses a Manual Trigger, you will be prompted to enter an input path.

  3. After the test completes, click on any component to view its Inputs, Outputs, and Traces. This is the primary way to debug your workflow's logic.

  4. Once the workflow behaves as expected, click Publish.

The agent will now be available in the Governance tab for consumption and monitoring.

You've now built and deployed a fully functional automated workflow -- ready to classify, process, and route incoming files with precision. Use this foundation to explore more advanced logic, integrations, and intelligent tasks across your enterprise workflows!