How to Save Tweets to a Spreadsheet Using Microsoft Power Automate
Updated: Nov 1, 2020
This article is going to show you how low-code no-code process automation tools can help you accomplish tasks that would otherwise be difficult and time-consuming to perform. Specifically, this article will show you how to use Microsoft Power Automate to extract tweet data from Twitter and save the data in a spreadsheet.
What is Microsoft Power Automate?
Microsoft Power Automate (formerly known as Microsoft Flow) is a low-code no-code tool that allows users to create automated workflows across a wide range of different apps and services. Using Microsoft Power Automate, users can create workflows that combine commonly used apps to automate mundane or repetitive tasks. Note that you will require a Microsoft account and an Office 365 subscription to follow the steps outlined in this article. Some of the links below are affiliate links, meaning that at no additional cost to you, I will earn a small commission if you click through and make a purchase. Click here to get your Office 365 Home annual subscription.
How to Save Tweets to a Spreadsheet Using Microsoft Power Automate
Step 1: Open your internet browser and navigate to https://flow.microsoft.com & login using your Microsoft account credentials. Note as outlined above, you will require an Office 365 personal or enterprise account to use Power Automate.
Step 2: On the Microsoft Power Automate landing page, click "Scheduled flow”.
Step 3: On the flow creation prompt, give the flow a name. A good practice is to name your flow something simple that describes specifically what the flow does. In this example, I'll name my flow "Scrape Twitter for NoCode Tweets".
Step 4: Select the date and time that you want the flow to execute on and then select how often the flow should run. We’ll have our flow trigger every day at 2:00pm.
Step 5: Click "Create" to create the flow.
Step 6: Click "New Step" to add the next action to the flow.
Step 7: In the "Choose an Action" box, search for the Twitter connector.
Step 8: In the "Twitter Actions" list select the "Search Tweets" action.
Note: Next, you will need to configure a connection to the Twitter account that you want to use. You will be prompted to enter your Twitter username and password and to grant Power Automate authorization to access your account. It is important that you review the Microsoft Terms of Service and learn about the risks associated with granting these permissions. After you have read the terms of service, click "Authorize App".
Step 9: The "Search Tweets" action box is where we fill out the parameters of the tweets that we want to extract and save to our spreadsheet. Enter the text that you want to search for in tweets in the "Search Text" field. In this example, I am going to search for tweets with "#nocode". Note that if you want to look for a specific phrase or text, you need to include it in quotations. For example, "No code". You can also search for tweets from a specific user by writing "from:@username".
Step 10: Enter the maximum number of tweets that you want to return from your search. In this example, I am going to return 20 tweets.
Step 11: Click "New Step".
Step 12: Next, you're going to choose where you want to save your tweet data. Microsoft Power Automate has multiple spreadsheet connectors for you to choose from. In this example, we are going to save our tweet data in a Google Sheet. In the "Choose an Action" box enter "Insert Row".
Step 13: If you want to save your tweets in a different spreadsheet such as a Smartsheet or an Excel spreadsheet, then select the respective action for either connector.
Step 14: If you want to use Google Sheets then select the Google Sheets "Insert Row" action.
Step 15: You will be prompted to sign in to your Google account to access the sheet that you want to save the tweet data to. Click "Sign in". Note that if you were using a different spreadsheet software then you'd be prompted to sign into your account for that software.
Step 16: Select or sign in to the Google account that you will use to create the Google Sheet with.
Step 17: Next, you will need to grant Microsoft Power Automate permission to access your Google Drive and Sheets. It is important that you review the Microsoft Terms of Service and learn about the risks associated with granting these permissions. After you have read the terms of service, click "Allow".
Step 18: You will then be prompted to select the Google Sheet file that you want to save the tweet data to. Note that this assumes that you have created a Google Sheet file in your Google Drive. If you have not, then go to Google Drive and create a Google Sheet and note where you saved this file. Click on the "folder icon" and then click on the ">" to the right of the "GoogleDrive" folder.
Step 19: You will then be able to navigate all of the folders in your Google Drive. Find the folder with your Google Sheet and then select that sheet. In this example, the Google Sheet is called "Twitter Extract".
Step 20: Select the worksheet of your Google Sheet file that you want to save the tweet data to. In this example, I am going to save it to "Sheet 1".
Step 21: After selecting the worksheet that you want to save the tweet data to, the Insert Row action box will update to display additional fields. These fields will represent the column headers that you have in your spreadsheet. Note that if you have not added column headers in your sheet, you can go back into your sheet and do so now. If you do this click on the "..." in the top right of the Insert Row action box, delete the action, and re-add it. In this example, I have added the following column headers: a) Tweet Text b) Tweeted by c) Retweet count and, d) Created at (which is the time it was tweeted).
Step 22: Now you will map the data that you want to extract from Twitter to your spreadsheet columns. To do this, click into one of your column header fields. Doing this will bring up the "Dynamic Content" box which will display all of the attributes of tweets that you can extract from Twitter. In this example, I have mapped the attributes that I want to extract to my column headers.
Step 23: You will also notice that a new action was added called "Apply to Each" and that the Insert Row action was nested inside this new action. The "Apply to Each" action is a loop action that will take the output of the previous step (search tweets and return 20 tweets that match our criteria), loop through them and, then for each tweet perform the Insert Row action.
Step 24: Now we're ready to test out the flow. Click "Save" and then click "Test".
Step 25: Click "I'll perform the trigger action" and then click "Test". Click "Run flow".
Step 26: The flow will execute and you should see the "Flow ran successfully" prompts.
Step 27: The last step is to open the Google Sheet file that you saved the tweet data to and verify that the data was saved successfully.
That's it. You've now successfully created a workflow automation that will extract tweet data and save it to a spreadsheet. If you found this article useful, be sure to subscribe to our newsletter to stay up to date on the latest low-code no-code updates and tutorials.