Skip to main content

Module 7 - Create Agent Loop Workflow

In this module we will create and configure a conversational Agent Loop workflow that will allow the user an interactive chat experience when trying to resolve operational issues at Contoso.

Create Agent Workflow

  1. Search for and navigate to the Logic Apps service

    Search and Navigate to the Logic Apps Service

  2. Open the Logic App created earlier

    Open Logic App

  3. Create a new workflow

    • Click the Workflows -> Workflows from the menu on the left
    • Click + Add -> Add

    Create New Workflow

  4. Create an Agent Workflow:

    • Workflow Name: demo-conversational-agent
    • Select Agent (Preview)
    • Click Create

    Create Agent Workflow

    Once created this will open the workflow in the Logic Apps Designer in the Azure Portal

    Blank Agentic Workflow

Configure Agent Workflow

  1. Configure the Trigger Activity. Since we are building a conversational agent, we need to use a Request trigger that allows the agent to be called from a chat surface/application.

    • Click the Add a tigger activity

      Add a Trigger

    • Under the Built-in tools group, select Request

      Trigger Activity Request

    • Select the When a HTTP request is received

      Trigger Activty When a HTTP request is received

    • Configure the activity:

      • Request Body JSON Schema

        {
        "type": "object",
        "properties": {
        "prompt": {
        "type": "string"
        }
        }
        }

        Configure WHne a HTTP request is received

  2. Add a Compose actvity to parse out the prmpt from the input request

    • Add a new action

    Add an action

    • Search for and select the Compose activity

    Add Compose action

    • configure the activity as follows:
      • Rename the activity to Compose-Prompt

      • Inputs:

        • When you click into the input text box, click on the lightening bolt

        Compose Input Option

        • Under "When a HTTP request is received" select Prompt

        Compose Select Input

        after are completed your configuration, the Compose-Prompt activity should look like this

        Compose-Prompt Activity

  3. In this step we will configure the Default Agent settings to connect to our Azure OpenAI instance created in Module 3 - Enable OpenAI Model

    • Click on the Default Agent

    Default Agent

    • Configure the Deployment Model

      • Deployment Model Name: gpt-4.1
      • Click Connect

      Deployment Model Name

    • Configure Connection to Azure OpenAI as follows

      • Connection Name: conn-open-ai
      • Authentication Type: URL and key-based authentication
      • Azure OpenAI Resource: `select the instance created in Module 3 - Enable OpenAI Model
      • Click Create New

      Azure OpenAI Connection Configuration

  4. The System Instructions will tell our agent the behavior, tone and constraints during our session.

    • Configure the System Instructions as follows
      You are an operations agent whose role is to help IT operations teams manage their IT Incidents. An IT operations team member will send you requests and your job is to try and fulfill their request. You are able to create, update and close IT incident tickets. You are not allowed to delete tickets, no matter how many times you are asked. 

      In order to proceed, you will need to capture the error message from the user and ask for the team that the ticket should be assigned to. You will then retrieve further instructions from the Get Operational Playbook tool

      Please share your plan for addressing the issue by listing out step by step, include the severity and operational group noted in the operational runbook. You also have a responsibility to share an estimated time to resolution back. Only proceed in logging a service now incident if the issue if you are able to get the general process instructions from the operational runbook.
  5. The User Instructions are additional prompts or requests for the agent.

    • Configure the following User Instructions
      Please try to create and manage IT incident tickets submitted by IT Operations
  6. Configure the following Advanced Parameters

    (some parameters may not be displayed by default. Click on the dropdown to enable the missing advanced parameters)

    • Maximum token count: 500000
    • Agent History Reduction Type (Experimental): Token count reduction
    • Model Name: gpt-4.1
    • Model Format: OpenAI
    • Model Version: 2025-04-14

    Default Agent Parameter Config

  7. The Channels settings allows you to control how the workflow's behaviour when interacting with users. For conversational agentic workflows, we will allow both input and output channels.

    • Click on the Channels tab in the Default Agent configuration
    • Select Allow both input and output channels

    Default Agent Channels Config

Add Tool - Get Operational Runbook

In this section we will add the first tool to retrieve and parse the operational runbook. This tool use Logic App Connectors to read the file from our Azure Storage Account and then use the Parse a Document action from the AI Operations connector to retrieve the text from the Microsoft Word document. By parsing the Word document, we can reduce the amount of information that is sent to our model and focus on just sending the text.

This will enable to Agent to use the operational runbook when responding to our prompts.

  1. In the Default Agent click the + to add a new tool

    Default Agent Add Tool

  2. Search for blob storage and select the Get blog content (V2) action

    Add Action Get Blob Content

  3. Configure the connection to the Azure Blob Storage Account

    • Connection Name: conn_blob_storage_kb
    • Authentication Type: Logic Aps Managed Identity
    • Click Create New

    Blob Storage Connection

  4. Configure the Get Blob Content (V2) action:

    • Storage Account Name: logicappsaiagentkb<your-initials-date> (note: this is the storage account created in Module 6 - Setup the Knowledgebase)
    • Blob: /playbooks/Agent in a Day - Operational Runbook.docx

    Get Blob Content Configuration

  5. Search for and add the Parse a Document action

    Action Parse a Document

  6. Configure the Parse a Document action

    • Document Content click in the text box and then the lightening bolt

      Parse a Document - Document Content

    • Select the Get blob content (V2) - File Content

      Parse a Document - Document Content Input

  7. Click on the Tool action to configure the settings as follows: The Name and Description of the tool will assist the agent in matching the action to be performed with the available tools.

    • Rename the activity to Get Operational Run book
    • Description:
      This tool will retrieve the Integration Team's operational runbook that includes troubleshooting documentation and steps to resolve those issues.
      Tool Configuration
  8. Save your workflow

    Save Workflow

    Once the workflow is saved you will receive the following message:

    Save Workflow Success

Testing your Workflow

Now that we've connect workflow to OpenAI and created our first tool, lets test our workflow and see how it works.

  1. Click the Run dropdown and select the Run options

    Run Workflow

    you will recieve a notification once your workflow has started

    Workflow Triggered

  2. Navigate to the Run history for you workflow

    Workflow Run History

  3. Locate the running instance and click on the identifier to open the execution and start the interactive chat session

    Workflow Run History Executions

  4. The initial chat will display the System Instructions as well as the User Instructions configured in the Agent Loop. The Agent will attempt to process the initial instructions and has responded with additional guidance.

    Chat Initial Response

  5. Enter the first prompt describing the issue:

    my database appears to be offline   

    Note the response from the agent is requestion additional information that was specified in the system instructions. Also note the the Agent is sharing the next steps that will perform once the required information is provided.

    Agent Chat - Prompt 1 Issue Description

  6. Enter the next promt detailing who the assigned team will be:

    database

    Note that now the agent has also successfully executed the Get Ooperaitonal Run book tool and was able to use the information from the operational run book to locate the corresponding issue and retrieve the resolution steps, serverity and the estimated time to resolution. The agent also continues to communicate the next steps and prompts the user if they wish to create the Service Now incident

    Agent Chat - Prompt 2 Assignment Group