This topic was automatically generated from Slack. You can find the original thread here.
Hello, I’m new to Pipedream and I’m struggling to get my head around the following task (Notion.so workflow). Your help would be greatly appreciated.
This topic was automatically generated from Slack. You can find the original thread here.
Hello, I’m new to Pipedream and I’m struggling to get my head around the following task (Notion.so workflow). Your help would be greatly appreciated.
Context:
I’m trying to automate things with the Notion.so API. I found many integrations and they work great as intended
My workflow goal is to fetch a database
within my Notion account and then update each entity
that qualifies for my needs.
I successfully retrieved and filtered all the records, but I don’t know how to update them since Notion is not providing a bulk-update endpoint and I didn’t find a Pipedream integration that would do the loop.
My issue:
Since I need to use Node.js code to make an update
loop I would like to reuse the Notion’s client
and configuration that was already used in a previous step (Pipedream action) when I fetched the database
, but I couldn’t find the configured client in the exported variables.
client
used in a previous action that I didn’t code myself?client
and asking for the same props (account and database ID)?await this.notion.anySupportedMethod() // this.notion already configured
PS: the Pipedream action I’m using to fetch the database
: pipedream/components/notion/actions/retrieve-database-content/retrieve-database-content.mjs at master · PipedreamHQ/pipedream · GitHub
You just need to ~configure~ select the client in a prop for your code step!
Meaning that I can’t reuse the client used in “Pipedreams’s fetch database” action?
You should be able to ~configure~ select the same client in both steps.
“select” is probably a better word to use than “configure”
Ok, I need to select the same client, but I have no idea on how to do that
Pipedream’s action doesn’t seem to export the client for me to reuse/select
Currently I copied everything here, thus I’m recreating the same client using the same code, but I don’t understand how to avoid doing that by selecting the already used client as you say so…
: What is the app name to use in props for the Notion.so API?
The app name to use in props for the Notion.so API is "notion"
. Here’s an example of how you would define it in a Pipedream component: ```
export default defineComponent({ props: { notion: { type: “app”, app: “notion”, }, } // the rest of the component … })
It’s working, many thanks !
Also, there is this part which allows the user to fill-in his database ID, and I’m wondering if I need to copy this code and all the methods it’s using internally or if there’s also a magic config I can use to access all these prop
utilities.
Unfortunately, these methods are not available within code steps.
I’ve made the same request myself many times, as it could indeed help to reuse existing code instead of writing/copying it each time.
FYI
Understood! You are giving me valuable information here. I wonder if it would make sense or if it’s even possible for myself to create a custom action which would export this configuration for me to reuse in my workflows. Thus copy/pasting it only once inside my custom action instead of everywhere I need it.
Thank you very much for your help. I feel more confident now and I’m ready to tackle future puzzles.
custom actions are indeed very useful, on our side we re-use them all over the place!
You actually can reference existing props defined in that app file. Since all app files are deployed as their own npm packages, you can import the package and then reference via propDefinition
. So if you wanted to use the databaseId
prop, you could do:
import { axios } from "@pipedream/platform"
import notion from "@pipedream/notion"
export default defineComponent({
props: {
notion,
databaseId: {
propDefinition: [
notion,
"databaseId",
],
},
},
async run({steps, $}) {
return await axios($, {
url: `https://api.notion.com/v1/users/me`,
headers: {
Authorization: `Bearer ${this.notion.$auth.oauth_access_token}`,
"Notion-Version": `2021-08-16`,
},
})
},
})
Try adding that code to a code step and then click the Refresh fields button above the code