Notion
Integrate the Ayrshare API into your Notion app to manage your users’ social media accounts
Overview
Notion is a workspace app that combines note-taking, project management, wikis, and a customizable database into a GUI interface.
From Notion, you can build an interface to manage your users’ social media accounts with Ayrshare’s social media API, allowing you to post, get analytics, and manage comments.
Tutorial
A video tutorial on how you can post to your social media networks directly from Notion. Also see our Notion API walk-though guide.
Github code of Notion social posting integration:
GitHub: Ayrshare Notion Integration
Post to your social media networks directly from Notion
Create a Notion Database
In Notion, create a database in table view with the following column names and column types:
Post
as Title column type (you don’t have a choice here with the column type)Platforms
as Multi Select column type with values:facebook
,instagram
,twitter
,linkedin
,tiktok
, and/ortelegram
.Images
as Files & Media column type .Profile Keys
as Text column type.Status
as Text column type.Schedule Date
as Date column type with Date Format Month/Day/Year, Time Format 24 Hours, and include time
These fields will be used in the script specified later in this page. Please note, some social networks “platforms” require images or videos. For example, Instagram requires and image or video and TikTok requires a video. Please see the endpoints for the different networks.
Enter in Test Post Data
We need some sample data to test the post. Here is a suggestion:
Post
: Enter “Happy New Year!”Platforms
: select one or more networks you have linked. Please be sure the name is lowercase.Images
: Attach an image or a video.
Profile Keys
: If you are on the Business Plan and want to post to a client’s profile, enter their Profile Key. Otherwise, leave blank.Status
: Enter “pending”. The script only grabs records that are set to “pending”. Please be sure “pending” is lowercase.Schedule Date
: Leave blank since we’ll just test immediate posting right now. Later you can select a future date to schedule the post.
Create Internal Integration in Notion
Go to the My Integrations page in Notion and click on New Integration.
Learn more about Notion Integrations.
You can name the integration “Ayrshare” to identify it easily and choose the appropriate workspace that will have the post data.
Finally, the default capabilities that have been selected for you will do. Submit to create the integration.
If successful, an internal integration token will be available to you. Note this for future steps in this page.
And gather your Notion integration token.
Connect Notion Database to the Internal Integration
Open the Notion database that you created earlier. Click on the ellipsis on the top right corner of the page and go to Add Connection.
Here you can search for the internal integration you created in the previous step by the name you chose for it.
Once you click on the internal integration, you have now connected this Notion database to the integration.
Run script to Send Posts from Notion
You can now run a script in your local environment that will read data from the Notion database and make a post through the Ayrshare API for each row in it with status of “pending”.
Make sure to set the following environment variables used in the script:
API_KEY
: this isAPI Key
you get from Ayrshare. This is the primary API Key for your Ayrshare primary profile.NOTION_DATABASE_ID
: Open the database you created earlier in this page and get the database ID from the URL.
NOTION_KEY
: internal integration token from earlier.
Run the following JavaScript in a Node.js environment:
- Clone the repository:
- cd into the notion directory and run
npm install
. Update the
.env
file with your AyrshareAPI_KEY
, NotionNOTION_KEY
andNOTION_DATABASE_ID
.- Run
node index.js
You can run it at Heroku, Digital Ocean, or Vercel in production.
If successful, all “pending’” status columns will be changed to “success’” and the posts will have been made to the appropriate social networks.
Github: Ayrshare Notion Integration
Post to your social media networks directly from Notion.