How can I search for a specific item within a previously retrieved Notion database

The problem I’m facing: I’m trying to search for a specific database item within a Notion database that I previously retrieved using the “Notion: Search a Database” module in Make.

Details:

My scenario consists of 6 main modules:

  1. Telegram Bot: Watch Updates: This module receives new messages from Telegram.
  2. Notion: Search a Database: This module searches for a database that matches the Telegram user ID (UID).
  3. Gemini AI: This module converts the user’s message into JSON format.
  4. JSON Parse: This module parses the JSON data.
  5. Notion: Search a Database (again): This module searches for a database item within the database found in Module 2, based on a value extracted from the parsed JSON. (See screenshot for details)
  6. Notion: Update a Database Item: This module updates a property within the database item found in Module 5.

The issue:

I’ve configured Module 5 as shown in the screenshot, but when I run the scenario, it fails with an error in Module 5. The error message indicates that the fields I’ve filled in are invalid.

  • Screenshot 1: Shows my Make scenario.
  • Screenshot 2: Shows the settings for Module 5. Here’s a breakdown:
    • 2. Database ID: This is the database ID retrieved in Module 2.
    • Tên công việc: This is a Title property in my Notion database.
    • 4. ma_cv: This is a text value extracted from the parsed JSON.
  • Screenshot 3: Shows the error message I receive when running the scenario (occurs in Module 5).

Workflow:

For example, if I send the message “Done 22” in Telegram:

  1. Module 1 receives the message and filters for my UID.
  2. Module 2 finds the corresponding database.
  3. Modules 3 and 4 convert “Done 22” into {"Ma_cv": "22"}.
  4. Module 5 should search for the database item where the “ma_cv” property ends with “22”.
  5. Module 6 should update the “Trạng thái” property of that item to “Done”.

Request:

I need help with configuring Module 5 and Module 6 correctly to achieve this workflow.

I’ve built the same automation before…

Let’s Solve This Step by Step

It sounds like you’re almost there, but a few things might need tweaking in your setup. Let’s make sure each part of your workflow is configured properly and working smoothly.

What You’re Trying to Do

You want to:

  1. Find the correct Notion database using a user ID from Telegram.
  2. Search for a specific item in that database using a value from a Telegram message (like “22”).
  3. Update a property (e.g., “Status”) for the matching item in Notion.

It’s a great workflow, and here’s how you can get it working without errors.

Breaking It Down

Step 1: Find the Database

  • In Module 2 (Notion: Search a Database), make sure you’re pulling the correct Database ID based on the user ID.
  • You can add a logging step (like a “Text” module or email notification) after this to double-check you’re getting the right database.

Step 2: Process the Telegram Message

  • When a Telegram message comes in (e.g., “Done 22”), your Gemini AI module should break it down into something like this:

Example:

{
“ma_cv”: “22”
}

  • Make sure this value (ma_cv) is correctly extracted and passed to the next module. You can log this output to verify it’s working as expected.

Step 3: Search for the Item in the Database

  • In Module 5 (Notion: Search a Database):
    • Database ID: Use the one you found in Step 1.
    • Filter: Set this up so it searches for an item where the property ma_cv matches or contains the value from Step 2.
      • If you want to search for items where ma_cv “ends with” a value like “22,” you might need to process the filter value first (e.g., use a “Text” module to handle this before passing it to Notion).
    • Double-check that the property name (ma_cv) matches exactly with what’s in your Notion database.

Step 4: Update the Item

  • In Module 6 (Notion: Update a Database Item):
    • Use the Page ID from the item you found in Step 3. This tells Notion which specific record to update.
    • Map the property you want to update (e.g., Status) to your desired value (e.g., “Done”).

Troubleshooting Tips

  1. Double-check the database schema in Notion:
    Ensure the property names and data types match what you’re sending. For example, ma_cv should be a text field if you’re sending “22” as text.
  2. Add logging steps:
    After each module, log the output to verify everything is working as expected. This will help pinpoint where things are breaking.
  3. Handle errors gracefully:
    If Module 5 doesn’t find a matching item, add a step to send a Slack message or log the issue instead of letting the scenario fail.

If Notion’s Filters Are Limiting

If you run into issues with Notion’s filtering (like “ends with”), you have a couple of options:

  1. Use Make’s tools: Preprocess the data (e.g., use a “Text” module to modify the filter value) before sending it to Notion.
  2. Go custom: If needed, you can use Make’s HTTP module to call Notion’s API directly for more advanced searches.

Next Steps

  1. Double-check each module’s configuration, especially the database and property filters.
  2. Add a few logging steps to ensure your data is flowing correctly.
  3. Test with a simple example (e.g., searching for “22”) and confirm it works.

Rephrased and Structured by GPT*