New RSS Item ID Existence Check and Addition in Google Sheets

This topic was automatically generated from Slack. You can find the original thread here.

Hi all! Can anyone offer guidance here—I have set my Trigger to be when a new item is created in my RSS feed. Now I am trying to take that item’s id and check whether it exists in my db (google sheets). If it does not, I want to add a new row to my google sheet and create a new ID for that item in a new column for that row.

Hi , I think your question is a great case for Pipedream bot to help. I’ll pass your question to the Pipedream bot now. Please feel free to ask it any question

Hi all! Can anyone offer guidance here—I have set my Trigger to be when a new item is created in my RSS feed. Now I am trying to take that item’s id and check whether it exists in my db (google sheets). If it does not, I want to add a new row to my google sheet and create a new ID for that item in a new column for that row.

To achieve this, you can follow these steps: 1. Set up your trigger as you’ve already done, using the “New Item in Feed” trigger for the RSS app. 2. Add a new step to your workflow using the “Search Rows” action from the Google Sheets app. Configure the step to search for the item’s ID in the specific column where you store IDs in your Google Sheet. 3. Add a conditional step to check if the search result is empty, which means the item’s ID doesn’t exist in your Google Sheet. 4. If the search result is empty, add another step using the “Add Row” action from the Google Sheets app. Configure the step to add a new row to your Google Sheet with the item’s ID and any other relevant information. Here’s a sample code snippet for the conditional step: if (steps.search_rows.$return_value.length === 0) { $respond({ status: 200, immediate: true, }); } else { $respond({ status: 500, immediate: true, }); } Replace steps.search_rows with the actual name of your “Search Rows” step. Remember to connect your Google Sheets account and configure the Google Sheets actions with the appropriate Sheet ID, range, and column values.

I do not understand the code snippet for conditional step, could you elaborate?

I apologize for any confusion. Let me explain the code snippet for the conditional step in more detail: if (steps.search_rows.$return_value.length === 0) { $respond({ status: 200, immediate: true, }); } else { $respond({ status: 500, immediate: true, }); } This code snippet checks if the search result from the “Search Rows” step is empty or not. If the search result is empty (meaning the item’s ID doesn’t exist in your Google Sheet), the code inside the first block will execute, and the workflow will continue to the next step with a 200 status. If the search result is not empty (meaning the item’s ID already exists in your Google Sheet), the code inside the second block will execute, and the workflow will stop with a 500 status. Please note that you should replace steps.search_rows with the actual name of your “Search Rows” step in your workflow. Let me know if you need further clarification or assistance.

Would it be better to set my trigger as a Scheduler?

Using a Scheduler trigger instead of the “New Item in Feed” trigger depends on your specific use case and requirements. If you want to check for new items in the RSS feed at specific intervals or at specific times, then using a Scheduler trigger would be a better option. With a Scheduler trigger, you can set up your workflow to run at specific intervals (e.g., every 5 minutes, hourly, daily) or use a custom cron schedule. In this case, you would need to fetch the RSS feed items within your workflow and then perform the same steps to check if the item’s ID exists in your Google Sheet and add a new row if it doesn’t. If you prefer real-time processing of new items in the RSS feed, then the “New Item in Feed” trigger would be more suitable, as it triggers the workflow as soon as a new item is detected in the feed.

Thank you my friend bot

You’re welcome! If you have any more questions or need further assistance, feel free to ask. I’m here to help!

just heads up I think the Search Rows action for Google Sheets is now called Find Rows

You’re correct! The “Search Rows” action for Google Sheets is now called “Find Rows.” Please use the “Find Rows” action when setting up your workflow. My apologies for any confusion, and thank you for pointing that out. If you have any more questions or need further assistance, feel free to ask.

I’m stuck on step 3. ‘Add a conditional step to check if the search result is empty, which means the item’s ID doesn’t exist in your Google Sheet.’

I am getting this error: Cannot read property ‘$return_value’ of undefined

I’ve added my conditional logic via a Node step, is that right?

I apologize for any confusion. Let me guide you through step 3 with a clearer explanation. After you’ve set up the “Find Rows” action in your workflow, you’ll need to add a conditional step to check if the search result is empty. To do this, follow these steps: 1. Click the “+” button below the “Find Rows” step in your workflow. 2. Select the “Run Node.js code” action. 3. In the code editor, paste the following code snippet: if (steps.find_rows.$return_value.length === 0) { $end("ID not found, continue to next step"); } else { $end("ID found, stop the workflow"); } Replace steps.find_rows with the actual name of your “Find Rows” step in your workflow. This code checks if the search result from the “Find Rows” step is empty (meaning the item’s ID doesn’t exist in your Google Sheet). If the search result is empty, the workflow will continue to the next step. If the search result is not empty, the workflow will stop. After adding this conditional step, you can proceed to add the “Add Row” action for Google Sheets as described in the previous response. Let me know if you need further clarification or assistance.

WOW thank you, I’ve got it now!

You’re welcome! I’m glad I could help. If you have any more questions or need further assistance, feel free to ask. Have a great time working with Pipedream!

What’s the difference between a ‘Write custom code’ action and a Node step where I can write my own custom JS?

In Pipedream, the “Write custom code” action and a Node step where you can write your own custom JavaScript both refer to the same concept. When you add a code step to your workflow, you can write custom Node.js code to perform various tasks, such as processing data, making API calls, or implementing conditional logic. To add a custom code step in your workflow: 1. Click the “+” button below any step of your workflow. 2. Select the option to “Run custom code”. 3. Select the nodejs14.x runtime. You can then write your custom Node.js code in the editor that appears. The custom code step uses the Monaco editor, which is the same editor used in Microsoft’s VS Code, providing syntax highlighting, automatic indentation, and more. If you have any more questions or need further assistance, feel free to ask.