If your Outlook inbox looks like something like
this, but you want it to look like this, I'm
going to show you how to get there by building
a simple autonomous AI agent in Microsoft Copilot
Studio. This autonomous AI agent will automatically
monitor your inbox as emails are coming in, decide
what folder to place them in, and notify you
on Teams for the urgent ones. My name is Shervin
Shafi and I'm a Copilot Principal Engineer at
Microsoft. now let's get started right now what
i'm going to do is i'm going to send an email
to arnold let me just send that it's coming from
albert so we're looking at arnold's inbox right
now and so here's albert einstein hey arnold
i'm your boss we need to meet right away last
time you said i'll be back and you never came
back albert And if we go over to the agent that
I built and we select activity, here's the email
that just generated this autonomous action. You'll
see that there's a trigger of when the email
comes in. It initializes this team's model context
protocol tool. It says trigger detected, which
is the email that came in. And then this agent,
which is email genie, we're just calling it that.
It uses this move email to move the email to
a folder. So if we switch over to the inbox,
you'll see that in this inbox, there is no email
anymore. However, on the left hand side, I created
these folders for customers, for internal and
for everything else. And you can see that there's
a one here. where this email from albert einstein
it just got moved into leadership and also if
i go over to arnold's teams i told the agent
to create a chat called urgent emails and another
chat that we'll look at as well the play by play
and here this is the notification urgent leadership
email received from albert and it has the message
as well and all of that is detailed here in the
activity of the agent the movement that happens
the message that gets posted using the teams
message and then below you're getting all this
information with respect to what's actually happening
and looks like there are no errors and then there's
also a play -by -play reporting that i asked
it to send inside teams so if we switch back
to teams and click on this play -by -play you'll
see that here you get this detailed of everything
that this agent does. Now let's look at how to
actually build this step by step. Okay, so the
first thing you're gonna need to do is you're
gonna go to a web browser and you're gonna type
in copilotstudio .preview .microsoft .com. The
preview is a trick that gives you access to preview
features. So if I actually go to my agents, I
have a bunch of different agents, some of which
you've seen in different videos. Now, if we go
to this email genie, we'll start from the top
and work our way down. So first, you give it
a name. You can select edit. And I gave it the
name email genie. And you can also change the
icon. I just found this cool picture, so I put
it in there. And then you give it a description.
And so the description here is this is an autonomous
agent that monitors your Outlook inbox and sorts
and organizes emails based on predefined rules
and priorities. Fair enough. Good description.
Next. You can select your agent's model. This
is pretty cool. Some of you may or may not have
seen this. Now you can actually specify the GPT
model from OpenAI. I'm using GPT -5 Auto, but
you can use anthropic models as well if your
IT admin has allowed you access. So that's a
question. The next part that's important is this
trigger. This is what wakes up the agent. So
the trigger that we use is this when a new email
arrives v3. and so all you need to do since you
won't have it yourself is you select plus add
trigger and you can see that if you select all
there's 844 triggers so you can you can look
for it or you can just type in something like
outlook email and then it'll look for those outlook
email triggers the one i use is when a new email
arrives v3 you select it you click next it asks
you to log in and if everything is okay then
you can basically click next and then it adds
it. So I'm not going to add it because I already
have it in there but that's the process. The
next thing is all the instructions and I put
a ton of detailed instructions in here to get
the agent to do what I want it to do. So this
is what I will copy and paste and put it in a
pinned comment so you can just copy and paste
the instructions into yours. But I highly suggest
that you modify them for your use case so you
can customize it to what is important to you.
Who is your boss? What's considered high priority?
Do you want to create a Teams chat for play by
play? All that kind of stuff. The details are
in here. But if we look at it kind of broadly,
I define the purpose, which is similar to the
description. And I also told it. Look, it's important
to remember that you're autonomous so that if
you have a question, don't ask me the question.
Just go ahead and execute it because I'm not.
I'm not chatting with you. You're just doing
things in the background. I don't know how effective
this instruction is, but so far it seems like
the agent is actually just making choices and
going ahead. And this depends on your model as
well. Then I told it that each time you run,
whether you're successful or not, I want a summary
report. This includes reports for what you did
and why for each email, as well as any error
handling anytime an error occurs or you can't
complete a task. Or even if you have a question
for me, you can send me a Teams message using
this microsoft teams mcp tool check to see if
there is already a one -on -one chat called email
genie play by play and if there is use it and
send me the summary if there isn't create one
so the first time it's going to create it and
then it should just see that there is one and
just reuse it over and over again that's why
when you go to mine the play by play you'll see
previous stuff because it's been reusing it including
the one that we just ran today so this is an
option for you to either keep this section or
remove it but I like to see the play -by -play
because I want to get an insight into into its
decision making this Microsoft Teams MCP tool
if we scroll down it's actually right over here
under this tool section so this is the Microsoft
Teams MCP tool and there's also this move email
v2 the move email v2 shows down here further
down here and For whatever reason, if I go to
edit, I can actually select slash and go to tools,
and then I'll be able to choose the move my email
V2, but MCP, I can't select it from this slash
menu. So I ended up calling it out specifically
up above. But both those tools are in the tools
section. We'll get to that in just a second.
Now the step -by -step instructions. outline
what this agent is supposed to do, right? First,
it's monitoring my inbox, detecting when new
emails arrive, which is done by that trigger.
And once the email is detected, then it proceeds
to step number two, which is classification.
And this section, number two, it determines the
folder for the email. It analyzes the email's
metadata, the sender's subject keywords, compares
it against categories. These are the categories
that I gave it, but you can change it. Categories
of customer email, internal emails, and everything
else. And so if we go back to Arnold's inbox,
you'll see that customer internal and everything
else is here. And then I further define internal
by internal leadership and internal informational,
like information from HR, company news, and so
on. And then my customers, I have different folders
that I've made up. These are actually not my
customers, but just pretend, right? Petco, Costco,
and so on. And then here's everything else. One
caveat with this agent is that there is no tool
to actually create the folder. So if you don't
create these folders, the emails are just gonna
stay in your inbox until you do. So just kind
of a heads up on that. Maybe in the future, we'll
add an action. to also create folders. And then
number three actually moves it to the correct
folder. So here we're saying for customer emails,
each customer will have its own subfolder. So
you saw the subfolders. And customer emails can
be from internal or external sources, right?
Your team can be talking to you about a customer
or the customer can actually be contacting you.
For internal emails that are not related to a
customer, classify as either informational or
leadership informational emails you can place
in a folder and any email from my leadership
consider urgent and requires a team message finally
anything that does not fit into these categories
that's everything else and place them in their
own folder so it uses this move email tool to
move the emails you have to call that out and
then when it's done and it goes to the next step
which is number four it notifies me of urgent
emails or emails from leadership like you saw
from albert the action is for any urgent email
send the team's message with the email summary
using this mcp tool so that is the instructions
which i'll copy and paste the knowledge is completely
blank web search is enabled doesn't really matter
and then the tools are the tools that I've been
using and referencing in the instructions now
for the tools all you got to do is Microsoft
Teams MCP and move email you select plus add
tool and here if you go to MCP model context
protocol you'll be able to find this Microsoft
Teams MCP I hope that you find it if some of
you don't have it maybe it's coming soon but
I've heard some people might not have this. And
if you don't, try using some of the other actions
that are just available as connectors. And the
other tool that we have, this move email V2.
So all you do is you go to add tool and then
here, just do a search for move email. And when
you search for it, then it should. show up here
so there it is move email v2 you select it there's
nothing else to it no agents no topics no suggested
topics that's all there was to it let's do a
little bit of testing as i send other emails
to this so here's an email that is kind of like
a junk email it's like a commercial of shopping
and then here's another one And this is Joe from
Bloomingdale's and we're interested in a co -pilot
studio. And the reason why I sent this is because
I don't actually have a Bloomingdale's under
my customer. So I want you to notice what ends
up happening, which is basically it should just
stay in here. All right, and so this is another
email saying that. This is sure from Petco and
we'd like to meet with you. This email should
get moved to Petco because there's actually a
folder. Now, one of the emails already disappeared.
So let's see where that went. And it actually
went into everything else. And so that was the
email that was basically commercial. It was just
junk. So it correctly moved it into everything
else. All right. It looks like another one of
the emails just got moved, which it is the Petco
one. So it got moved correctly to the Petco one.
And then this one, the one that's from Bloomingdale's,
I suspect nothing is going to happen to it because
there's no folder for it. So that's it. I hope
this makes sense. And this is something that
you can execute for your own inbox. And I do
want to give you one other tip. If in case you
have an issue and you're like, oh, I don't like
this. It's not working. You can always go to
the agent and all you got to do is go to the
trigger section, select these three dots and
delete the trigger. As soon as you delete that
trigger, there is no more trigger for the incoming.
And so this agent is not going to be doing anything.
So just as a heads up, you can always get rid
of the agent by just deleting the trigger. And
then you can fix your instructions and add the
trigger back in to make it go live again. So
it's as easy as that. Let me know if. you've
made updates and improvements to the instructions
or you added some other components to this agent
to improve it so you might be thinking well sure
there's already ways of sending emails to folders
like if you go to outlook which you're looking
at here and you go to settings you can actually
then go under mail go to rules and you can add
a new rule and you can set the different conditions
like if an email is coming from a certain person
or there's certain keywords you can then move
them from an action perspective into different
folders but this is not really using ai so it's
not dynamic from an intelligence perspective
it's very static and it's also not notifying
you of urgent emails and team and then you might
be wondering well sure there's another feature
coming out and it's called outlook prioritize
my inbox by copilot and it basically prioritizes
your inbox by copilot marking high priority items
i've shown this in the past and i actually have
this feature it's rolling out at the moment so
it's now fully out and people have been asking
about it then this is kind of what the feature
looks like and you can tell it things that are
higher priority and things that are lower priority
still this isn't doing the folder routing as
well as the notification inside team so this
is good and i'm only showing these because i
want to show people that there are alternatives
so if you're not into building an agent in copilot
studio you can just stop right now