This script will make it easier to automatically invite specifc guests to a private Notion page without making it public.
Getting started:
Setting up the script
-
Log in to your Cloudflare workers dashboard, go to the workers tab, and then add a new service.
-
Give your script a name and then click the 'create service' button.
-
Remove all previous code and paste the following script code into the editor.
Click
Quick edit
buttonPaste the script code in the editor and click the
Save and Deploy
button -
You must now configure the following environment variables:
Navigate to your Worker > Settings > Variables and add the following secrets:
TOKEN_V2
paste the value of your Notion token (required)SLACK_WEBHOOK
paste your Slack webhook URL (optional to receive notification via Slack)
⚠️ Encrypt the data you enter for security reasons. by pressing the Encrypt button -
Add the name of your Notion workspace to your environment variables.
-
If you return to the editor and click the
preview
tab, then clickrefresh
you should get this message.{"data":{"message":"script is running!"}}
That's it, now that you've correctly configured the script, next i’ll show you how to use it.
How to use the script?
Using automation tools such as (Make, Zapier…)
After deploying the script, you will be given a public link to your API.
for example mine is https://notioninvites.d3vlab.workers.dev
To invite a new user, make a POST request with the parameters listed below.
Required:
email
the user email that you want to invite
pageid
your notion page id
Optional (default is comment)
permission
the permission you want to grant to the invitee
fullaccess → can edit and share with others
edit → can edit but not share with others
comment → can view and comment but not edit
view → cannot edit or share with others
Example:
If I want to invite a guest to this page, the request url will be
ℹ️ make sure you add `/invite` path after the base urlIn make, for example, you can use the HTTP module and a variable to dynamically specify the user email address.
After you run the workflow, the user will be instantly invited.
With Gumroad
Gumroad setup is much simpler, simply go to your Gumroad dashboard > settings > advanced and enter your API url followed by /gumroad
path in the Ping section.
for example mind is:
https://notioninvites.d3vlab.workers.dev/gumroad
ℹ️ Please keep this link private because anyone who obtains it will be able to invite users to your page.- When you create a product, you must include your Notion
page id
in the link.
That's it, whenever a guest make a new purchase, Gumoard will automatically submit the user information, and the script will invite the user to the page.
Congratulations, you have successfully set up the script 🥳 If you have any questions, feel free to ask me on Twitter, and if you want to support me, you can donate here, which would be greatly appreciated ❤️