Skip to content

Building AI Workflows: Step-by-Step Examples

Learn how to build practical AI workflows in OR through hands-on examples. This guide shows you how to combine AI components with your data to create intelligent workflows.

What You'll Learn
  • Build a basic Prompt → LLM workflow
  • Extend AI workflows with web search capabilities
  • Save AI-generated results to your data schema
  • Chain multiple AI components together
  • Choose the right AI component for your use case

Before You Start

Make sure you can:

  • Open OR and create a workflow
  • Add components from the component library
  • Create operators/connections between tasks
  • Run a workflow test
  • Access logs and task outputs
  • Access your project's data schema / GraphiQL view (for the export example)

Example 1: Create a Basic Prompt → LLM Workflow

This first example sends a text prompt into an LLM and returns a generated answer.

Step 1: Create a New Workflow

Create a new workflow in OR.

Use a clear name, for example:

  • AI modelling

Once created, open the workflow.

Step 2: Add a String Constant

In the component panel:

  1. Search for string
  2. Open Data management
  3. Open Constants
  4. Drag String Constant into the workflow canvas

This component will hold the prompt text that you want to send to the model.

Why Use a String Constant?

A constant is useful when you want to:

  • Define a reusable input value
  • Test a workflow quickly without building a front end first
  • Simulate a user prompt while developing

Step 3: Add an LLM Task

In the component panel:

  1. Search for LLM
  2. Open the AI modelling section
  3. Open Agents section
  4. Drag LLM Agent - Single task call onto the canvas

You should now have:

  • A String Constant
  • An LLM Agent Single Task Call

on the workflow canvas.

Step 4: Create an Operator to Connect Them

You now need to connect the constant to the LLM task and map the constant value into the LLM input.

Create a new operator.

Set:

  • workflow: AI modelling
  • workflow task name: prompt to llm
  • Preceding workflow task: Data Managment - Constants
  • Operator input key: prompt
  • Operator input type: MdkDataConstantStringModelResponse
  • Following workflow task: AI and Modelling - Agent
  • Operator output type: TaskInputs
  • Operator name: prompt to LLM
  • Operator description: prompt to LLM

This operator sits between the two tasks and defines how data moves from one to the other.

How to Choose Preceding and Following Tasks

A good rule is:

  • The task sending data is the preceding task
  • The task receiving data is the following task

In this case:

  • The string constant sends the prompt text
  • The LLM receives and uses that prompt

Step 5: Map the Constant Value into the LLM Input

When configuring the operator, map the string constant's value into the LLM task input.

In the LLM task input structure, find the field that represents the user content or prompt text. Replace the default content value with:

prompt.value

The exact field label may vary slightly in the UI, but the goal is the same: the LLM's content field should receive the String Constant's value.

Once mapped, save or create the operator.

You should now see the operator positioned between the String Constant and the LLM task.

Step 6: Update the Prompt Text

Edit the String Constant and replace the default example value with a real prompt.

For example:

Write me a poem about Melbourne.

Save the change.

Step 7: Run the Workflow

Run a test execution of the workflow.

The workflow should execute the constant first, then the operator mapping, then the LLM task.

Step 8: Inspect the Output

Open the LLM task output after the run (the last task output).

You may see one of two behaviors:

  • The generated answer appears directly in the task output, or
  • The task output only shows status information and a Redis reference

If the output is not shown directly, continue to the next step.

Step 9: Enable Raw Output

Open the LLM Agent Single Task Call configuration.

Go to:

  • Parameters

Find the setting:

  • raw output

Set it to:

  • true

Save the configuration.

Run the workflow again.

Now the generated answer should appear directly in the task output content.

Step 10: Review Metrics

For LLM tasks, you may also see metrics such as:

  • Token usage
  • Input/output token counts
  • Estimated cost

These metrics help you understand AI usage and monitor model cost.

What This Example Teaches

This basic workflow demonstrates how to:

  • Provide a prompt as workflow input
  • Map that prompt into an AI task
  • Run an LLM inside a workflow
  • Inspect outputs and metrics
  • Configure output behavior with raw output

Example 2: Use AI for Real-World Queries

Now that the basic LLM workflow is working, you can try a more realistic prompt.

Step 1: Change the String Constant Prompt

Edit the String Constant and replace the poem prompt with a factual question, for example:

How many hospitals are there in Melbourne?

Run the workflow again.

Step 2: Review the Result

In some cases, a general LLM may not provide a useful answer to a live or current factual question.

This is because:

  • The model may not have the right external context
  • The model may not have access to tools
  • The answer may require current web data

If the LLM returns an incomplete answer, fails, or says it cannot provide a result, that is expected behavior for some prompts.

This is the point where tool-based agents become useful.


This example adds a web-enabled AI component so the workflow can retrieve information from the internet.

Step 1: Add a Web Search Agent

In the component panel:

  1. Search for web
  2. Open AI modelling
  3. Open Agents
  4. Drag Web Search Agent onto the canvas

Your canvas should now include:

  • String Constant
  • LLM Agent Single Task Call
  • Web Search Agent

Step 2: Connect the AI Output to the Web Search Agent

Create a connection from the earlier AI task into the Web Search Agent.

After creating the connection, open that connection's configuration and set:

"output dependency = true"

Save the connection.

Why This Works

Many AI tasks in OR use the same underlying task input format. That means you can often:

  • Replace one agent with another
  • Chain agents together
  • Test different AI approaches with minimal workflow changes

Step 3: Confirm the Input Shape (Optional)

If you want to confirm whether two AI tasks are compatible:

  1. Open the task menu for the target task
  2. Choose Preview input
  3. Look for the shared task input structure

This is useful when deciding whether two components can be connected directly.

Open the Web Search Agent configuration.

In Parameters, set:

raw output = true

Save the configuration.

Step 5: Run the Workflow

Run a test execution.

Then inspect the Web Search Agent output.

Expected Result:

Web Search is more suitable than a plain LLM for current factual questions, but the answer may still be limited because:

  • Search results may be broad rather than precise
  • The top pages found may not contain the exact answer
  • The tool may provide a summary rather than a definitive value

Example 4: Try Web Scraper for Targeted Extraction

If Web Search does not give a strong answer, try Web Scraper.

Step 1: Add a Web Scraper Agent

In the component panel:

  1. Search for web
  2. Open AI modelling → Agents
  3. Drag Web Scraper Agent onto the canvas

Step 2: Connect the Workflow into Web Scraper

Create a connection into the Web Scraper Agent.

Configure the connection with:

output dependency = true

Save the connection.

Step 3: Enable Raw Output

Open the Web Scraper Agent configuration.

Set:

raw output = true

Save the configuration.

Step 4: Install MCP if Prompted

Web Scraper depends on an MCP service.

The first time you run this task, the workflow may fail and prompt you to install an MCP server or model.

  1. Go to AI and Modelling
  2. Go to Agent Tools
  3. Drag in search and scrape web results

Important Note

Web Scraper may take longer to start than a plain LLM because it may need extra services to initialize.

Step 5: Review the Output

Run the workflow again and inspect the Web Scraper output.

For targeted factual extraction, Web Scraper may perform better than Web Search because it is intended to crawl and extract specific information rather than simply returning general search results.


When to Use Each AI Component

Use an LLM When You Want To:

  • Generate text
  • Summarize known inputs
  • Transform or classify content
  • Answer questions based on provided context

Use Web Search When You Want To:

  • Perform broad internet lookup
  • Retrieve general web-based summaries
  • Augment a workflow with current public information

Use Web Scraper When You Want To:

  • Extract specific facts from websites
  • Gather targeted information from public pages
  • Search more deeply than a simple top-results search

User documentation for Optimal Reality