How to use Microsoft Flow to automate simple, repetitive tasks
Use Microsoft Flow to publish a file to SharePoint and post about it in Teams
Today I want to walk you through a simple custom Flow that I have created to help streamline a process that I use to prepare and publish blog articles, with the help of my team. Even though this is a specific use case, the Flow that I am building has many possible applications. Before we dive into it, here is the process that I am trying to simplify for myself.
When I start drafting a new article, I generally do so right from OneDrive, in a folder called “Blogs.”
OneDrive is where a lot of my work starts out, since I am not ready to share it while it is still in a “very rough draft” form, but the idea is to eventually share this content with other people. Now in the past after I have completed my first draft, I have either emailed this document to my marketing team, or, more recently, I have been uploading the documents into our Marketing channel within Teams.
Either process requires me to open another application, draft a message to notify my team, and then attach or upload the files myself. But like many tasks that basically come down to “paper pushing,” why not have Flow do this stuff for me?
Here’s how. Let’s start with the simple task of copying a file from one place (my OneDrive) to another (like a SharePoint library that my team uses).
First, I will create a new folder called “Ready for review” where I can easily drag and drop the articles that I have completed. My plan is that, Flow will take action when it sees a document show up in this folder.
From the top ribbon in OneDrive, I select Flow > See your flows. This brings me to the Flow app. Here I click on + New and choose Automated—from blank. (I didn’t find a template that did exactly what I wanted, —so I’ll just build one from scratch).
Skip ahead to go right into the full editor (I find the actual editor is easier and more intuitive than the wizard actually). From the editor, you can (1) give it a descriptive name at the top, and then (2) choose OneDrive for Business to get a list of triggers from OneDrive.
The trigger we are looking for is called: When a file is created (preview). This is a newer version of the option above it, and in my testing, it works better to achieve the result I’m looking for.
Here I simply use the folder picker to navigate to the path that I created in my OneDrive earlier: /Blogs/Ready for review. Then click + New step.
In the second step, I want Flow to create this same file in SharePoint. So I will search for “create file sharepoint”—then I can pick the option I want: Create file
To build this second step, I can just fill in the fields it needs as follows:
- Site Address: Using the drop-down menu, I will pick out the Marketing site where I want to post the content
- Folder Path: Next I pick out the folder path I want to use from the folder icon in the second field
- File Name and File Content: I can fill in these fields using the Add dynamic content option. This selector will pull and display available attributes from our first step in the process, “When a file is created” from OneDrive.
- Pick File name for the File Name field
- Pick File content for the File Content field
Remember I also want to Post a message to Teams. To do this, choose + New step again. Select Teams or use search to find the right action. Let’s use V3 (the latest and greatest at the time of this writing).
Similar to what we’ve seen before, I can easily pick out the Team and the Channel I want to post in. Then, I can format the message I would like posted in the Channel every time I use this Flow.
We could stop right here and have a pretty awesome flow. But then again, I don’t really need to keep that original copy in my OneDrive once it has been “passed over the fence” to my team. So why not add one more step to delete the original file and eliminate version sprawl?
In the Flow designer, choose + New Step and search for “delete file onedrive.”
I always find it ironic that OneDrive is actually “TwoDrives.” The one I want out of this list is Delete file—specifically the second one subtitled OneDrive for Business—because I am not connecting to my “Personal” or “consumer” OneDrive account but rather the Business account that is associated with my company’s Office 365 subscription. Just be aware of this distinction when you are working in here.
Again, I will want to pick the option to Add dynamic content (which comes from a previous step or trigger in the flow). So I can just scroll down and find the option called File identifier under the heading When a file is created (NOTE: it should have the OneDrive icon next to it—this means the original file that was created in OneDrive from the first step).
When you’re all set, be sure to Save your flow.
So let’s see this thing in action, shall we? Let’s say my blog post is completed, and I am ready to send it over the fence to my teammates, who will provide feedback and edits as needed before passing it along (again) to our website guy for final publishing. I have a draft right now that’s ready to go, in fact!
Like a lot of people, I still tend to work out of File Explorer rather than a web interface, so I can just drag and drop my completed file into the “Ready for review” folder, and let Flow do the work from there!
Note that a flow may not be triggered instantly—this particular trigger fires every 5 minutes looking for new things to do. So, after about 5 minutes, as expected, my draft has found a new home in my team’s SharePoint site (with a message announcing its arrival in Teams).
The SharePoint path that I picked out corresponds to a location within the “Files” tab in this channel:
From this point the team has everything they need to start collaborating about the content in Teams, providing feedback, editing it, or whatever they need to do in order to get the article published. One of the marketing team members may even decide to create their own approval process in Flow, and have the result automatically shipped out via email to our web guru, who ultimately posts it online.
So to review, my personal workflow went from:
Draft a blog post in Word > Upload a copy to SharePoint > Draft a message in Teams or email to notify my team members > Delete the original file from OneDrive (optional)
Draft a blog post in Word > Drag n’ Drop (done)
Pretty slick, huh? This Flow saves me a few steps, and several minutes of my time, every time I go to complete this fairly menial task. Totally worth the effort, don’t you think?
What tasks do you want to automate? Let us know.