How to Create Self-Operating Agents in Copilot Studio Using Event Triggers: Email-Activated Automation (Preview)

In this article, I’ll demonstrate how to create an autonomous agent that automatically responds to emails using the recently added “Triggers” feature in Copilot Studio.

スポンサーリンク

Event Triggers

Event triggers function similarly to Power Automate triggers, allowing agents to be activated by events such as “receiving an email” or “data addition/update.”
Since these events, rather than user messages, initiate the agent, you can easily create autonomous agents that operate independently.

Using this feature, I’ll show you how to build an agent that activates when an email is received.

Sample Implementation: Activation upon Email Receipt

To use this feature, you need to enable the orchestration functionality.
*Note: As of January 3, 2025, this requires the language to be set to English and generative AI to be turned ON.
Screenshot showing the orchestration feature enablement settings in Copilot Studio

Adding an Event Trigger

First, click on [Add trigger],
Screenshot showing the Add trigger button location in Copilot Studio
Select “When a new email arrives”,
Screenshot showing the trigger selection with 'When a new email arrives' option highlighted
Once the connection is established, click [Next].
Screenshot showing the connection establishment screen with Next button
Since this is just a sample, only specify “Mail folder” and click [Create trigger].
Screenshot showing the mail folder configuration with Create trigger button
Once the trigger is added, click [Edit in Power Automate].
Screenshot showing the added trigger with Edit in Power Automate button

Power Automate Configuration

When you open Power Automate, you’ll see that “Trigger” and “Send prompt to Copilot” actions are added by default.
Screenshot showing Power Automate with default trigger and Send prompt to Copilot actions
Since we’re creating a flow that notifies Copilot of the received email content, use the [Select] action to narrow down to the minimal necessary information,
Screenshot showing the Select action configuration to filter email information
And send a prompt to Copilot. When doing this, make sure to include “prompt instructions for Copilot” in this Body/message field.
*Note: I got stuck when I initially just passed the output from the “Select” action thinking that was enough information – Copilot didn’t respond at all…
Screenshot showing the Send prompt to Copilot action with instructions in the body field

Creating the Topic

When the flow we just created is executed, it sends a prompt to Copilot. Since I wrote “Activate the ‘Email Received’ topic” in the prompt, we need to create this corresponding topic.

Create a new topic, name it “Email Received”, and create a string argument to receive the output from the [Select] action in Power Automate.
Screenshot showing the topic creation with Email Received name and string argument configuration

Next, use the [Parse value] node to prepare the string passed from Power Automate to be handled as a JSON object.
Screenshot showing the Parse value node configuration to handle the input as JSON

Since the email receipt trigger can pass multiple received emails, add a Foreach to process all of these emails.
Screenshot showing the Foreach configuration to handle multiple emails

Finally, send a message within the loop notifying about the received email,
Screenshot showing the message configuration inside the loop to notify about received email
And ask if a reply should be sent to complete the implementation.
Screenshot showing the configuration of asking whether to reply to the email

Testing

To test the functionality, you need to run the Power Automate flow once beforehand.
Screenshot showing Power Automate flow run history
Return to the [Overview] page and click the test trigger icon,
Screenshot showing the test trigger icon on the Overview page
Select the execution history of the Power Automate flow we just ran, and click [Start test].
Screenshot showing the selection of flow execution history and Start test button
A debug message indicating the trigger has activated will be displayed, followed by the “Email summary” and “Do you want to reply?” messages we created in the topic.
Screenshot showing the debug message and email summary with reply option
When you click Yes, the left side of the condition branch is executed.
Screenshot showing the execution of the Yes branch of the condition

Now you just need to add a Power Automate action to send a reply before the “I’ve replied” message is sent, and you’ll have an agent that automatically replies to emails (in theory).

Of course, receiving this message for every email would be annoying, so you’d need to use AI Builder or another AI service to determine in advance “whether a reply might be necessary.”

Issue 1: Creator’s Connection is Used

There’s an important caution: with this implementation, it seems that Outlook is accessed using the “creator’s” connection. This means if you share it with other users, they might potentially see your emails.
Screenshot showing that the creator's connection is used for Outlook access

I’m still exploring methods for deploying this to other users.

Issue 2: Not Working When Executed in Teams

I tried triggering it several times after deploying to Teams,
Screenshot showing the trigger in Teams environment
But for some reason, it’s not working…
Screenshot showing the trigger not working in Teams

I’m currently investigating this issue as well.

Bonus: There Are Limitations on Knowledge Sources Referenced by Event Triggers

When activated by event triggers, agents may not be able to access the following knowledge sources:

  • SharePoint
  • Dataverse
  • Graph connectors
  • AI Builder prompts

Related Articles

コメント

Copied title and URL