# Notion Integration

> Part of the [NextBlog documentation](https://nextblog.ai/docs.md). Live page: [https://nextblog.ai/docs/integration-notion](https://nextblog.ai/docs/integration-notion)

Seamlessly sync your blog posts with Notion databases for collaboration and content management. This integration converts markdown to Notion blocks and creates new pages in your database automatically.

#### Prerequisites

Before you begin, make sure you have:

- A Notion account with workspace access
- Permission to create integrations in your workspace
- A Notion database (or create a new one) to sync posts to

### Step 1: Create Notion Integration

#### 1.1 Visit Notion Integrations Page

Go to [https://www.notion.so/my-integrations](https://www.notion.so/my-integrations)

#### 1.2 Create New Integration

1. Click the **"+ New integration"** button
2. You'll be prompted to name your integration

#### 1.3 Configure Integration

Fill in the integration details:

- **Name:** Enter `NextBlog Integration` (or any name you prefer)
- **Associated workspace:** Select the workspace where your database is located
- **Type:** Select `Internal`
- **Capabilities:** Make sure `Read content` and `Insert content` are enabled

#### 1.4 Copy Integration Token

1. After creating the integration, you'll see the **"Internal Integration Token"**
2. **Important:** Copy this token immediately and save it securely. It starts with `secret_`
3. You can view this token again later, but it's best to copy it now

### Step 2: Create or Select Notion Database

#### 2.1 Create New Database (Optional)

If you don't have a database yet:

1. Open Notion and navigate to the page where you want the database
2. Type `/database` and select "Table - Inline" or "Table - Full page"
3. Name your database (e.g., "Blog Posts")

#### 2.2 Set Up Database Properties

Your database should have these properties (they can be created automatically, but it's better to set them up):

- `Name` - Title property (this is the default, required)
- `slug` - Text property
- `description` - Text property
- `image` - Files & media property
- `imageAlt` - Text property
- `isReady` - Checkbox property

**Note:** If these properties don't exist, they will be created automatically when the first post is synced.

### Step 3: Share Database with Integration

#### 3.1 Open Database

Open the Notion database you want to sync posts to

#### 3.2 Add Integration Connection

1. Click the **"..."** menu (three dots) in the top right of the database
2. Select **"Add connections"** or **"Connections"**
3. Find and select your `NextBlog Integration`
4. Click **"Confirm"** or **"Add"**

**Important:** Without this step, the integration won't have access to your database and syncing will fail.

### Step 4: Get Database ID

#### 4.1 Copy Database URL

1. Open your Notion database in a web browser
2. Copy the URL from your browser's address bar
3. The URL will look like: `https://www.notion.so/workspace/DATABASE_ID?v=...`

#### 4.2 Extract Database ID

The Database ID is the 32-character string between your workspace name and the `?` character.

**Example:**

```text
URL: https://www.notion.so/myworkspace/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6?v=...
Database ID: a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
```

**Tip:** The Database ID is 32 characters long and contains letters and numbers. Remove any hyphens if present.

### Step 5: Configure Notion Integration in NextBlog

#### 5.1 Navigate to Project Settings

1. Log into your NextBlog dashboard
2. Click on your project to open it
3. Click on **"Settings"**

#### 5.2 Enable Notion Integration

1. Scroll down to the **"Notion Integration"** section
2. Toggle the **"Enable Notion Integration"** switch to ON

#### 5.3 Enter Notion Credentials

Fill in the following fields:

- **Notion Integration Token:** Paste the token you copied in Step 1.4 (starts with `secret_`)
- **Notion Database ID:** Paste the Database ID you extracted in Step 4.2 (32 characters)

#### 5.4 Test Connection

1. Click the **"Test Connection"** button
2. Wait for the test to complete
3. If successful, you'll see a green success message
4. If it fails, check:
  - That the database is shared with your integration (Step 3)
  - That the token and database ID are correct
  - That you have access to the workspace

#### 5.5 Save Changes

Click the **"Save Changes"** button to save your Notion integration settings.

### How It Works

Once configured, here's what happens when you approve a blog post:

1. **Post Approval:** When you approve a blog post in NextBlog, the Notion integration is triggered
2. **Content Conversion:** The markdown content is converted to Notion blocks (headings, paragraphs, lists, etc.)
3. **Page Creation:** A new page is created in your Notion database with:
  - `Name` property set to the post title
  - `slug` property with the post slug
  - `description` property with the post description
  - `image` property with the cover image URL
  - `imageAlt` property with the image alt text
  - `isReady` checkbox set to true
4. **Content Blocks:** The full blog post content is added as Notion blocks in the page body
5. **Completion:** The page is ready for viewing and collaboration in Notion

### Troubleshooting

#### Connection Test Fails

**Common issues:**

- **Database not shared:** Make sure you completed Step 3 and shared the database with your integration
- **Invalid token:** Check that you copied the entire token correctly (it should start with `secret_`)
- **Wrong database ID:** Verify the 32-character ID is correct and doesn't include hyphens or extra characters
- **Workspace access:** Make sure your integration has access to the workspace containing the database

#### Posts Not Syncing

**Check the following:**

- Make sure the integration is enabled in project settings
- Verify the connection test passes
- Check that you're approving posts (not just generating them)
- Look for error messages in your NextBlog dashboard
- Check Notion for any permission errors

#### Content Not Appearing Correctly

**Possible causes:**

- Complex markdown formatting may not convert perfectly - review and adjust in Notion if needed
- Images must be publicly accessible URLs
- Very long posts may take a moment to sync completely

### Next Steps

Now that your Notion integration is set up:

- Generate or create a blog post in NextBlog
- Review and approve the post
- Check your Notion database - a new page should appear automatically!
- Use Notion's collaboration features to work with your team on the content
