Skip to main content

Prerequisites

  • Node.js installed on your machine
  • A Mailchimp account
  • A Notion account

Step 1: Get Your API Keys

Mailchimp API Key
1
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.
Notion API Key
1
Log in to your Notion account.
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
Create a package.json file and add the following:
JSON

Step 6: Configure Mailchimp and Notion API clients

Create mailchimp.js to set up the Mailchimp API client. Ensure your credentials are being passed here.
JavaScript
Repeat to create notion.js :
JavaScript

Step 7: Set Up Connections

Create mailchimpIntegrations.js to fetch campaigns and subscribers from Mailchimp:
JavaScript
Additionally, create notionIntegrations.js to populate the Notion Database:
JavaScript

Step 8: Main Script

Create a main.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
Customize the code to match your Notion database structure and desired properties for each campaign or subscriber. Add error handling and further customization as needed for your specific requirements.