How to Add Code Snippets for Notion API Filtering in Pipedream and Check if a Contact Already Exists?

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

Good Day, any chance someone has a quick moment to help me figure out where & how I’m supposed to add the code snippets for Notion API filtering in Pipedream? I want to add new Orders from my LemonSqueezy into two separate Notion Databases. The 1st capturing the Contact info, and the second capturing the Order detail (those two pages would then be related to one another) —— but I want to first check if the contact exists first… I’m having trouble figuring out how to search (filter) a Database by an Email property column. (edited)

Here’s a screenshot of my attempt… though I just kinda threw some AI generated lines of code in between a section then replaced certain values to try & make it connect to my workspace/database/email-property. I’m sure the code will look horrible to anyone who’s proficient in JS, so pardon me lol.

Hi Sean, good question. I would start by reading about querying databases over their API here:

Then you can filter by email address from your Lemon Squeezy order details

Hey, yeah I guess I am far too new to using Javascript, but I just don’t know how or where to place the filter code lines when it comes to the Pipedream side.

When you first create a Node.js action for Notion, it pre-populates with some code… and I’m guessing it’s necessary? So I just didn’t know how or where to modify it with the specific code injections from the Notion API

Right, exactly. The scaffolding Notion JS code shows you how to make an authenticated API request to a sample Notion API endpoint.

You’ll need to modify the URL, method and body of the request to match the endpoint you’re trying to interact with.

I suggest watching our University series on using code steps first, just to get the hang of the structure:

This doc in particular helps show how Pipedream passes your Notion API key into the request:

awesome, thank you for those direct resources. I’ll spend some time trying to figure it out.

Sure thing. You’ll just have to look at the scaffolded Node.js code and compare it against that Notion API endpoint for querying a database, and just try to run a sample request first. Then learn how to modify the request to pass that email value dynamically.

not gonna lie I’m pretty overwhelmed by this & feel as though I should have learned JavaScript years ago to be able to make this make sense… not sure why the smallest things are foiling me on this lol, but okay. I’ll keep trying to get through it and make sense of it. Appreciate ya.

Sure thing. There are quite a few Javascript basics courses out there. Any one of them should teach the fundamentals, then you can learn how to send API requests, which unlocks this power to integrate apps together like you’re trying to here.