Autonomous Agents are here! (preview)

If you have been following any of the announcements from Microsoft around Copilot Studio than you might have heard the term autonomous agents before. For you who have no idea what I am talking about, let me explain what this is. An autonomous agent is an AI driven agent (previously known as Copilot) that can automate business processes by making decisions and completing tasks on its own without needing constant human supervision. We can almost compare autonomous agents with an assembly line (except for the making decisions part.) Let’s use a car manufacturing assembly line as an example. An assembly line designed to optimize the car manufacturing process is usually divided into various stations or work cells, each dedicated to a specific task (e.g., stamping, welding, painting, assembly). Each station is equipped with the necessary tools and machinery. In this scenario the autonomous agent is the assembly line, the car is the business process, and the different components of the agent (topics, actions, connectors, etc.) are the work stations dedicated to specific tasks. Makers use the instructions to tell the agent what it needs to do, which actions to use and in which order, which almost makes up a digital assembly line. Of course this is not exactly the same, because autonomous agents can reason and make decisions, and might even skip certain steps, depending on what’s needed which means the car assembly line could decide to make different car brands or decide to use different colors dependent on the needs, but hopefully this comparison makes it a bit clearer. Organizations can have multiple autonomous agents that handle different processes. For example, you could create an autonomous agent that handles customer refunds, where the agent would find the customer’s order, check if the order has warranty on it, after which it would decide to give the customer a refund or not. Another example is an agent that handles an employee onboarding process, where hardware like laptops and monitors need to be ordered for the new employee, and a new hire training needs to be scheduled. The options are endless!
Autonomous agents can be configured to react to different triggers than what we were previously used to: Any of the custom agents we have built in Copilot Studio react when someone initiates a chat with the agent, but autonomous agents can be triggered by other things, like the creation of a record in dataverse, or the arrival of an incoming email. During this preview there are 51 triggers available to use, with hopefully more to come in the future.

Scenario

In order to give everyone a better understanding of what an autonomous agent can do, I will build (a very simple) one and describe the entire process in this article so you can try this yourself as well. For this example I am going to create an autonomous agent that will run the onboarding process for new customers. The business process is as follows:

  • Sales rep sends an email with the subject ‘Account Onboarding” and the body of the email contains customer information, like the customer name and their phone number.
  • A new account row will be created in dataverse with the information from the email.
  • The new account will be assigned to the sales rep who sent the email in step 1.

The agent will be triggered when an new mail is received with the subject ‘Account Onboarding’. I will create a power automate flow that I will turn into an action which will extract the account’s name and phone number from the email. It will use that information to create a new account record in dataverse. I will create a second power automate flow, (which I will also turn into an action) which will use the sender’s email address to find the sales reps’ unique ID from dataverse. The power automate flow will then use that ID to assign the newly created account to the sales rep. NOTE: I realize that I could’ve assigned the account owner in one flow but I wanted to showcase the ability to have multiple actions, where the agent is smart enough to pass data from one action into another!

Create the agent in Copilot Studio

The first thing I’ll do is create a new agent in copilot studio. You can do this by clicking on the ‘+ Create’ button on the left side of the screen, and selecting ‘New Agent’. In the ‘Description’ I enter:

“This agent will create a new account record in D365 when an email is received with the subject line ‘Account Onboarding.’ and in the Instructions section I enter: ‘You are tasked with managing Account Onboarding requests received via email. An account is a new customer. Your responsibilities include analyzing the request, creating a new account in Dataverse and assigning it to the original sender of the email. It is crucial to follow every step precisely and complete all actions listed once, without skipping any. Once all actions are completed your work is finished. When you receive an email with the subject “Account Onboarding” perform the following tasks without asking the user for confirmation.

1. Analyze the incoming email you received. Extract the account name and the phone number and create a new account record in Dataverse by using the Create account action.
2. Assign the sender of the email as the owner of the newly created account by using the Set account ownership action.”

To save my inputs I click the ‘Create’ button on the top of the screen. After the Agent loads on the screen, I navigate to Settings > Generative AI and set the ‘How should your agent interact with people’ to “Generative (preview)’. I also make sure that the ‘Orchestration is set to ‘use generative AI to determine how best to respond to users and events (preview).’

Configuration

I can set the trigger for this agent from the ‘Overview’ page of the agent. When I click ‘+ Add trigger’ a list of power platform connectors opens up for me to choose from. By changing the filter from ‘Featured’ to ‘All’ I see even more trigger options! Since I want this agent to trigger when an email arrives, I am going to use the ‘When a new email arrives V3’ trigger. This will open a screen where I can change the trigger name and it shows the credentials it will be using for this trigger. After clicking the ‘Next’ button I am taken to a screen where I can configure more details. Since I only want to trigger this flow on emails that have the subject line ‘Account Onboarding’, I will enter ‘Account Onboarding’ in the subject line field. I can also enter the actual mailbox that I want the agent to monitor, so I enter my mailbox. After clicking the ‘Create Trigger’ button, the trigger shows up under ‘Triggers’ in the agent. NOTE: Creating a trigger also creates a Power Automate flow in the backend, which you can edit by clicking on the ellipse and selecting ‘Edit in Power Automate’.

As I mentioned earlier, I am going to use two simple power automate flows as actions. The first power automate flow is called ‘Create Account’. It will extract the account name and phone number from the email and create an account row in dataverse. It will then pass the unique ID of the account record back to the agent. This is needed, as I will create a second power automate flow, where I will assign the newly created account to the user that sent the email. But in order to find the account, I will need it’s unique ID.

‘Create Account’ Power Automate Flow

I navigate to Actions from within the agent and I click ‘+ Add an action’. This will bring up the page from which I can select where to create the action from. Since the Power Automate Flow hasn’t been created yet, I scroll down and click the ‘Create a new flow’ button. This will open the flow designer. I click on the ‘Run a flow from Copilot’ trigger and enter two text inputs. One is called ‘Account Name’ and the second is called ‘Main Phone’. These are placeholders, this data will come from the autonomous agent. I then add the ‘Add a new row’ (Dataverse) action. I rename the step to ‘Create Account’ and I select ‘Accounts’ as the table name. I set the ‘Account name’ placeholder from the trigger in the ‘Account Name’ field in the step parameters. I also populate the ‘Main Phone’ field with the ‘Main Phone’ placeholder from the trigger. I click on the ‘Respond to Copilot’ step and add one text output called ‘AccountID’. I enter the output from ‘Account’ (unique identifier of the account) in the ‘AccountID’ output. Then I click the ‘save’ button to save the flow and close the window.

‘Create account’ Action

Back in Copilot Studio I can now select my newly created flow for my action. (If you don’t see your flow, make sure you refresh the screen.) Once you select the ‘Create Account’ flow click on ‘Next’ to edit the inputs. I will update the description fields for the inputs to tell the agent the type of data that I am looking for in each input. For the ‘Account Name’ input I enter “Name of the account’ and for the ‘Main Phone’ input I enter ‘Phone number in the standard US format, extracted as a string.’ I then click on ‘Outputs’ to edit the description of the output variable. For the AccountID output I enter ‘The unique identifier of the account record in dataverse.’ I click ‘Back’ and then ‘Next’ which takes me to the “Review and Finish’ screen. I click ‘Edit’ on the Configure section to update the description for the agent to know when to use this action. I enter :’This action will create a new account in Dataverse from the onboarding email that was received.’ I click ‘Finish’ to save the action.

‘Set Account Ownership’ Flow

Now let’s create the second power automate flow. I navigate to ‘Actions’ again and I click ‘+ Add an action’. I scroll down again and click the ‘Create a new flow’ button. This opens the flow designer yet again. I click on the ‘Run a flow from Copilot’ trigger and enter two text inputs. One is called ‘Email address’ and the other is called ‘AccountID’. Then I add a new action called ‘List Rows’ (dataverse). The table name is Users and under ‘Filter rows’ I enter ‘internalemailaddress eq ‘ followed by a single quote and the ‘Email address’ placeholder from the trigger, follwed by another single quote. I set the row count to 1. The next action in this Power Automate flow is a ‘Compose’ (Data Operation) action. I rename the action to ‘Get UserID’ and enter the following expression: body(‘List_rows’)[‘value’][0][‘systemuserid’] This will give me the guid of the user who sent the email. I then add the ‘Get a row by ID’ (Dataverse) action and rename the step to ‘Get account’. In the step parameters, I enter ‘Accounts’ as the tablename and I set the ‘AccountID’ placeholder from the ‘Run a flow from Copilot’ trigger as the row id. After this I add one more action, which is another dataverse action called ‘Update a row’. Here I will change the owner of the account to the sender of the email. I select ‘Accounts’ as the table name and enter ‘Account’ from the ‘Get account’ step in the row id field. I then scroll down to the ‘Owners’ field and enter systemusers/ followed by the output of the ‘Get UserID’ compose step. I save the flow and close the window.

‘Set Account Ownership’ Action

Back in Copilot Studio I can now select my newly created flow for my action. (If you don’t see your flow, make sure you refresh the screen.) Once you select the ‘Set account ownership’ flow click on ‘Next’ to edit the inputs. I will update the description fields for the inputs to tell the agent the type of data I am looking for in each input. For the ‘Email address’ input I enter: ‘Email address of person who sent the email’, for the ‘AccountID’ input I enter ‘The unique identifier of the account record in dataverse.’ I click ‘Back’ and then ‘Next’ which takes me to the “Review and Finish’ screen. I click ‘Edit’ on the Configure section to update the description for the agent to know when to use this action. I enter :’This action assigns the sender of the onboarding email as the owner of the newly created account.’ I click ‘Finish’ to save the action.

Testing!

Now it’s time to test my work! First I need to publish the agent, once that’s done I send an email from another user account to the email address in my environment. In order to see what is happening, I can navigate to the ‘Activity’ tab where all the triggered ‘runs’ will be visible. This is a list of times the agent was triggered and went through the processes I configured. After a few minutes I see my first ‘run’ show up, where it shows me if this was an automated trigger or if it was triggered by a user (you can test the agents trigger, which will make it show up in the activity list under the name of the person who manually triggered the agent). It also shows the date the agent was triggered, and a summary of some sort. Makers can drill into each individual ‘run’ to see the agent’s thought process, and drill into the individual steps to see the inputs and outputs in the steps. Unfortunately I didn’t see a way to ‘cancel’ any runs that show a status of ‘in progress’.

Final Thoughts

Mark my words, Autonomous agents are going to change the digital landscape completely! At this stage agents might still need some babysitting, after all, this is still AI and AI can make mistakes as well, but as the tech gets better and AI learns and understands more, it will completely change how applications are built and how organizations operate. I hope you enjoyed this article, let me know what you think in the comments! Be sure to check in again next week for a new article or subscribe here to never miss another post!

Share this!

Leave a Reply