Prerequisites
- Node.js installed on your machine
- A Mailchimp account
- A Notion account
Step 1: Get Your API Keys
Mailchimp API Key1
Log in to your Mailchimp account.
2
Navigate to your profile by clicking on your account name in the lower-left corner.
3
Go to Profile.
4
Click on the Extras dropdown and select API keys.
5
Click on Create A Key.
6
Copy the generated API key.
1
Log in to your Notion account.
2
Go to Notion Connections.
3
Click on New Connection.
4
Fill in the required details and click Submit.
5
Copy the generated internal connection API token.
Step 2: Set Up Your Notion Database
1
Create a new database in Notion with the following properties:
- Campaign Name (Title)
- Name (Text)
- Email (Email)
2
Share the database with your connection:
- Click on the three dots in the top-right corner of the page.
- Under Connections, click on Connect to and search for your connection and invite it.
Step 3: Project Structure
This step is not necessary but we suggest projects to be structured like so:Step 4: Create .env file
Create a.env file in your project directory with the following content, replacing the placeholders with your actual credentials:
YAML
Step 5: Packages
Install the required Node.js packages using the following command:Shell
package.json file and add the following:
JSON
Step 6: Configure Mailchimp and Notion API clients
Createmailchimp.js to set up the Mailchimp API client. Ensure your credentials are being passed here.
JavaScript
notion.js :
JavaScript
Step 7: Set Up Connections
CreatemailchimpIntegrations.js to fetch campaigns and subscribers from Mailchimp:
JavaScript
notionIntegrations.js to populate the Notion Database:
JavaScript
Step 8: Main Script
Create amain.js file that uses the modules created above to execute the connection logic.
JavaScript
Step 9: Run the Connection
Execute the connection script by running the following command:Shell