Is It Possible to Import Files from the Notion Component into a Custom Action/Step in Pipedream?

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

Hey everyone.
I am a novice in Pipedream and i am trying to make some workflows for automating stuff in Notion, that i can not do with the available actions.

Question:
Can i import files from the Notion component?
There is an action called duplicate page inside Pipedream and inside the action there is these imports:

import notion from "../../notion.app.mjs";
import base from "../common/base-page-builder.mjs";
import utils from "../../common/utils.mjs"; 

Can i somehow import them in my own custom action/step?

Yup! Each component is published as an npm package.

For example, you can import the @pipedream/notion npm package and use the main notion.app.mjs file as an module:

import notion from '@pipedream/notion'

// notion is the notion.app.mjs file exported from the Pipedream registry

Dylan - thank you for that.
It is because the duplicate page action only works for duplicating a page to another page but don’t for a page within a database.

const page = {
      parent: {
        page_id: this.parentId,
      },
      properties: {
        title: utils.buildTextProperty(title),
      },
      cover: this.isFile(cover)
        ? null
        : cover,
      icon: this.isFile(icon)
        ? null
        : icon,
      children: formattedChildren,
    };

The parent object should use database_id instead if the parent is a database… So i had to write my own action doing essentially the same.

Oh nice catch Jesper. Sounds like this action might be useful to others integrating Notion. Did you know you can open PRs and contribute your actions back to the main repo?

Hi Dylan. No i am completely new to Pipedream and NodeJS/Javascript is not among my core competencies - but i managed to get it to work though.

How do I contribute, then I might polish my soulution and open a PR.

Oh, very nice. That’s impressive you were able to track that down and make your own component.

Here’s the official guide: Components Guidelines & Patterns - Pipedream

But you can also join the channel here for help. Don’t worry about opening a rough PR, the PD developers will give you helpful feedback, they don’t bite