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
-
Search for and navigate to the Logic Apps service
-
Open the Logic App created earlier
-
Create a new workflow
- Click the
Workflows -> Workflows
from the menu on the left - Click
+ Add -> Add
- Click the
-
Create an Agent Workflow:
- Workflow Name:
demo-conversational-agent
- Select
Agent (Preview)
- Click
Create
Once created this will open the workflow in the Logic Apps Designer in the Azure Portal
- Workflow Name:
Configure Agent Workflow
-
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 -
Under the Built-in tools group, select
Request
-
Select the
When a HTTP request is received
-
Configure the activity:
-
Request Body JSON Schema
{
"type": "object",
"properties": {
"prompt": {
"type": "string"
}
}
}
-
-
-
Add a Compose actvity to parse out the prmpt from the input request
- Add a new action
- Search for and select the Compose activity
- 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
- Under "When a HTTP request is received" select
Prompt
after are completed your configuration, the Compose-Prompt activity should look like this
-
-
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
-
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
- Connection Name:
-
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.
- Configure the System Instructions as follows
-
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
- Configure the following User Instructions
-
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
- Maximum token count:
-
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
- Click on the
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.
-
In the Default Agent click the
+
to add a new tool -
Search for blob storage and select the
Get blog content (V2)
action -
Configure the connection to the Azure Blob Storage Account
- Connection Name:
conn_blob_storage_kb
- Authentication Type:
Logic Aps Managed Identity
- Click
Create New
- Connection Name:
-
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
- Storage Account Name:
-
Search for and add the
Parse a Document
action -
Configure the
Parse a Document
action-
Document Content click in the text box and then the lightening bolt
-
Select the
Get blob content (V2)
-File Content
-
-
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.
- Rename the activity to
-
Save your workflow
Once the workflow is saved you will receive the following message:
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.
-
Click the
Run
dropdown and select theRun
optionsyou will recieve a notification once your workflow has started
-
Navigate to the
Run history
for you workflow -
Locate the running instance and click on the identifier to open the execution and start the interactive chat session
-
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.
-
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.
-
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