diff --git a/docs/docs/integrations/notion/add-content-to-page.md b/docs/docs/integrations/notion/add-content-to-page.md
new file mode 100644
index 000000000..44069f7c9
--- /dev/null
+++ b/docs/docs/integrations/notion/add-content-to-page.md
@@ -0,0 +1,133 @@
+import Admonition from "@theme/Admonition";
+import ThemedImage from "@theme/ThemedImage";
+import useBaseUrl from "@docusaurus/useBaseUrl";
+import ZoomableImage from "/src/theme/ZoomableImage.js";
+
+# Add Content To Page
+
+Langflow allows extending its functionality with custom components like `AddContentToPage`, which converts markdown text to Notion blocks and appends them to a Notion page.
+
+[Notion Reference](https://developers.notion.com/reference/patch-block-children)
+
+## Component Functionality
+
+The `AddContentToPage` component enables you to:
+
+- Convert markdown text to Notion blocks.
+- Append the converted blocks to a specified Notion page.
+- Seamlessly integrate Notion content creation into Langflow workflows.
+
+## Component Usage
+
+To use the `AddContentToPage` component in a Langflow flow:
+
+1. **Add the `AddContentToPage` component** to your flow.
+2. **Configure the component** by providing:
+ - `markdown_text`: The markdown text to convert.
+ - `block_id`: The ID of the Notion page/block to append the content.
+ - `notion_secret`: The Notion integration token for authentication.
+3. **Connect the component** to other nodes in your flow as needed.
+4. **Run the flow** to convert the markdown text and append it to the specified Notion page.
+
+## Code Block for the `AddContentToPage` Component
+
+```python
+import json
+from typing import Optional
+
+import requests
+from langflow.custom import CustomComponent
+
+
+class NotionPageCreator(CustomComponent):
+ display_name = "Create Page [Notion]"
+ description = "A component for creating Notion pages."
+ documentation: str = "https://docs.langflow.org/integrations/notion/add-content-to-page"
+ icon = "NotionDirectoryLoader"
+
+ def build_config(self):
+ return {
+ "database_id": {
+ "display_name": "Database ID",
+ "field_type": "str",
+ "info": "The ID of the Notion database.",
+ },
+ "notion_secret": {
+ "display_name": "Notion Secret",
+ "field_type": "str",
+ "info": "The Notion integration token.",
+ "password": True,
+ },
+ "properties": {
+ "display_name": "Properties",
+ "field_type": "str",
+ "info": "The properties of the new page. Depending on your database setup, this can change. E.G: {'Task name': {'id': 'title', 'type': 'title', 'title': [{'type': 'text', 'text': {'content': 'Send Notion Components to LF', 'link': null}}]}}",
+ },
+ }
+
+ def build(
+ self,
+ database_id: str,
+ notion_secret: str,
+ properties: str = '{"Task name": {"id": "title", "type": "title", "title": [{"type": "text", "text": {"content": "Send Notion Components to LF", "link": null}}]}}',
+ ) -> str:
+ if not database_id or not properties:
+ raise ValueError("Invalid input. Please provide 'database_id' and 'properties'.")
+
+ headers = {
+ "Authorization": f"Bearer {notion_secret}",
+ "Content-Type": "application/json",
+ "Notion-Version": "2022-06-28",
+ }
+
+ data = {
+ "parent": {"database_id": database_id},
+ "properties": json.loads(properties),
+ }
+
+ response = requests.post("https://api.notion.com/v1/pages", headers=headers, json=data)
+
+ if response.status_code == 200:
+ page_id = response.json()["id"]
+ self.status = f"Successfully created Notion page with ID: {page_id}\n {str(response.json())}"
+ return response.json()
+ else:
+ error_message = f"Failed to create Notion page. Status code: {response.status_code}, Error: {response.text}"
+ self.status = error_message
+ raise Exception(error_message)
+```
+
+## Example Usage
+
+Example of using the `AddContentToPage` component in a Langflow flow using a Markdown as input:
+
+
+
+In this example, the `AddContentToPage` component connects to a `MarkdownLoader` component to provide the markdown text input. The converted Notion blocks are appended to the specified Notion page using the provided `block_id` and `notion_secret`.
+
+## Best Practices
+
+When using the `AddContentToPage` component:
+
+- Ensure markdown text is well-formatted.
+- Verify the `block_id` corresponds to the right Notion page/block.
+- Keep your Notion integration token secure.
+- Test with sample markdown text before production use.
+
+## Troubleshooting
+
+If issues arise:
+
+- Verify the Notion integration token’s validity and permissions.
+- Check the Notion API documentation for updates.
+- Ensure markdown text is properly formatted.
+- Double-check the `block_id` for correctness.
+
+The `AddContentToPage` component is a powerful tool for integrating Notion content creation into Langflow workflows, facilitating easy conversion of markdown text to Notion blocks and appending them to specific pages.
diff --git a/docs/docs/integrations/notion/notion-list-database-properties.md b/docs/docs/integrations/notion/list-database-properties.md
similarity index 93%
rename from docs/docs/integrations/notion/notion-list-database-properties.md
rename to docs/docs/integrations/notion/list-database-properties.md
index 702bd1fb7..bd399d4a4 100644
--- a/docs/docs/integrations/notion/notion-list-database-properties.md
+++ b/docs/docs/integrations/notion/list-database-properties.md
@@ -7,6 +7,8 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
Langflow allows you to extend its functionality with custom components. The `NotionDatabaseProperties` component is designed to retrieve properties of a Notion database. It provides a convenient way to integrate Notion database information into your Langflow workflows.
+[Notion Reference](https://developers.notion.com/reference/post-database-query)
+
The `NotionDatabaseProperties` component enables you to:
- Retrieve properties of a Notion database
@@ -29,15 +31,17 @@ Here's the code block for the `NotionDatabaseProperties` component:
```python
import requests
from typing import Dict
+
from langflow import CustomComponent
from langflow.schema import Record
+
class NotionDatabaseProperties(CustomComponent):
display_name = "List Database Properties [Notion]"
description = "Retrieve properties of a Notion database."
- documentation: str = "https://developers.notion.com/reference/post-database-query"
+ documentation: str = "https://docs.langflow.org/integrations/notion/list-database-properties"
icon = "NotionDirectoryLoader"
-
+
def build_config(self):
return {
"database_id": {
@@ -61,14 +65,17 @@ class NotionDatabaseProperties(CustomComponent):
url = f"https://api.notion.com/v1/databases/{database_id}"
headers = {
"Authorization": f"Bearer {notion_secret}",
- "Notion-Version": "2022-06-28", # Use the latest supported version
+ "Notion-Version": "2022-06-28", # Use the latest supported version
}
+
response = requests.get(url, headers=headers)
response.raise_for_status()
+
data = response.json()
properties = data.get("properties", {})
+
record = Record(text=str(response.json()), data=properties)
- self.status = f"Retrieved {len(properties)} properties from the Notion database.\n{record.text}"
+ self.status = f"Retrieved {len(properties)} properties from the Notion database.\n {record.text}"
return record
```
diff --git a/docs/docs/integrations/notion/notion-list-pages.md b/docs/docs/integrations/notion/list-pages.md
similarity index 97%
rename from docs/docs/integrations/notion/notion-list-pages.md
rename to docs/docs/integrations/notion/list-pages.md
index 15c1c2120..726381ce6 100644
--- a/docs/docs/integrations/notion/notion-list-pages.md
+++ b/docs/docs/integrations/notion/list-pages.md
@@ -3,11 +3,13 @@ import ThemedImage from "@theme/ThemedImage";
import useBaseUrl from "@docusaurus/useBaseUrl";
import ZoomableImage from "/src/theme/ZoomableImage.js";
-# Database Query
+# List Pages
Langflow allows you to extend its functionality with custom components. The `NotionListPages
` component is designed to query a Notion database with filtering and sorting. It provides a convenient way to integrate Notion database querying capabilities into your Langflow workflows.
+[Notion Reference](https://developers.notion.com/reference/post-database-query)
+
> **Tip**:
>
> ### Component Functionality
@@ -50,7 +52,7 @@ class NotionListPages(CustomComponent):
"Example input:\n"
'{"filter": {"property": "Status", "select": {"equals": "Done"}}, "sorts": [{"timestamp": "created_time", "direction": "descending"}]}'
)
- documentation: str = "https://developers.notion.com/reference/post-database-query"
+ documentation: str = "https://docs.langflow.org/integrations/notion/list-pages"
icon = "NotionDirectoryLoader"
field_order = [
diff --git a/docs/docs/integrations/notion/notion-list-users.md b/docs/docs/integrations/notion/list-users.md
similarity index 94%
rename from docs/docs/integrations/notion/notion-list-users.md
rename to docs/docs/integrations/notion/list-users.md
index 152fefe46..0e77801ed 100644
--- a/docs/docs/integrations/notion/notion-list-users.md
+++ b/docs/docs/integrations/notion/list-users.md
@@ -7,6 +7,8 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
Langflow allows you to extend its functionality with custom components. The `NotionUserList` component is designed to retrieve users from Notion. It provides a convenient way to integrate Notion user data into your Langflow workflows.
+[Notion Reference](https://developers.notion.com/reference/get-users)
+
> **Component Functionality**
>
> The `NotionUserList` component enables you to:
@@ -28,15 +30,17 @@ Here's the code for the `NotionUserList` component:
```python
import requests
from typing import List
+
from langflow import CustomComponent
from langflow.schema import Record
+
class NotionUserList(CustomComponent):
display_name = "List Users [Notion]"
description = "Retrieve users from Notion."
- documentation: str = "https://developers.notion.com/reference/get-users"
+ documentation: str = "https://docs.langflow.org/integrations/notion/list-users"
icon = "NotionDirectoryLoader"
-
+
def build_config(self):
return {
"notion_secret": {
@@ -47,34 +51,44 @@ class NotionUserList(CustomComponent):
},
}
- def build(self, notion_secret: str) -> List[Record]:
+ def build(
+ self,
+ notion_secret: str,
+ ) -> List[Record]:
url = "https://api.notion.com/v1/users"
headers = {
"Authorization": f"Bearer {notion_secret}",
"Notion-Version": "2022-06-28",
}
+
response = requests.get(url, headers=headers)
response.raise_for_status()
+
data = response.json()
results = data['results']
+
records = []
for user in results:
id = user['id']
type = user['type']
name = user.get('name', '')
avatar_url = user.get('avatar_url', '')
+
record_data = {
"id": id,
"type": type,
"name": name,
"avatar_url": avatar_url,
}
+
output = "User:\n"
for key, value in record_data.items():
output += f"{key.replace('_', ' ').title()}: {value}\n"
output += "________________________\n"
+
record = Record(text=output, data=record_data)
records.append(record)
+
self.status = "\n".join(record.text for record in records)
return records
```
diff --git a/docs/docs/integrations/notion/notion-add-content-to-page.md b/docs/docs/integrations/notion/notion-add-content-to-page.md
deleted file mode 100644
index 84cad1a75..000000000
--- a/docs/docs/integrations/notion/notion-add-content-to-page.md
+++ /dev/null
@@ -1,307 +0,0 @@
-import Admonition from "@theme/Admonition";
-import ThemedImage from "@theme/ThemedImage";
-import useBaseUrl from "@docusaurus/useBaseUrl";
-import ZoomableImage from "/src/theme/ZoomableImage.js";
-
-# Add Content To Page
-
-Langflow allows extending its functionality with custom components like `AddContentToPage`, which converts markdown text to Notion blocks and appends them to a Notion page.
-
-## Component Functionality
-
-The `AddContentToPage` component enables you to:
-
-- Convert markdown text to Notion blocks.
-- Append the converted blocks to a specified Notion page.
-- Seamlessly integrate Notion content creation into Langflow workflows.
-
-## Component Usage
-
-To use the `AddContentToPage` component in a Langflow flow:
-
-1. **Add the `AddContentToPage` component** to your flow.
-2. **Configure the component** by providing:
- - `markdown_text`: The markdown text to convert.
- - `block_id`: The ID of the Notion page/block to append the content.
- - `notion_secret`: The Notion integration token for authentication.
-3. **Connect the component** to other nodes in your flow as needed.
-4. **Run the flow** to convert the markdown text and append it to the specified Notion page.
-
-## Code Block for the `AddContentToPage` Component
-
-```python
-import json
-from typing import List, Dict, Any
-from markdown import markdown
-from bs4 import BeautifulSoup
-import requests
-
-from langflow import CustomComponent
-from langflow.schema import Record
-
-class AddContentToPage(CustomComponent):
- display_name = "Add Content to Page [Notion]"
- description = "Convert markdown text to Notion blocks and append them to a Notion page."
- documentation: str = "https://developers.notion.com/reference/patch-block-children"
- icon = "NotionDirectoryLoader"
-
- def build_config(self):
- return {
- "markdown_text": {
- "display_name": "Markdown Text",
- "field_type": "str",
- "info": "The markdown text to convert to Notion blocks.",
- "multiline": True,
- },
- "block_id": {
- "display_name": "Page/Block ID",
- "field_type": "str",
- "info": "The ID of the page/block to add the content.",
- },
- "notion_secret": {
- "display_name": "Notion Secret",
- "field_type": "str",
- "info": "The Notion integration token.",
- "password": True,
- },
- }
-
- def build(self, markdown_text: str, block_id: str, notion_secret: str) -> Record:
- html_text = markdown(markdown_text)
- soup = BeautifulSoup(html_text, 'html.parser')
- blocks = self.process_node(soup)
-
- url = f"https://api.notion.com/v1/blocks/{block_id}/children"
- headers = {
- "Authorization": f"Bearer {notion_secret}",
- "Content-Type": "application/json",
- "Notion-Version": "2022-06-28",
- }
-
- data = {
- "children": blocks,
- }
-
- response = requests.patch(url, headers=headers, json=data)
- self.status = str(response.json())
- response.raise_for_status()
-
- result = response.json()
- self.status = f"Appended {len(blocks)} blocks to page with ID: {block_id}"
- return Record(data=result, text=json.dumps(result))
-
- def process_node(self, node):
- blocks = []
- if isinstance(node, str):
- text = node.strip()
- if text:
- if text.startswith('#'):
- heading_level = text.count('#', 0, 6)
- heading_text = text[heading_level:].strip()
- if heading_level == 1:
- blocks.append(self.create_block('heading_1', heading_text))
- elif heading_level == 2:
- blocks.append(self.create_block('heading_2', heading_text))
- elif heading_level == 3:
- blocks.append(self.create_block('heading_3', heading_text))
- else:
- blocks.append(self.create_block('paragraph', text))
- elif node.name == 'h1':
- blocks.append(self.create_block('heading_1', node.get_text(strip=True)))
- elif node.name == 'h2':
- blocks.append(self.create_block('heading_2', node.get_text(strip=True)))
- elif node.name == 'h3':
- blocks.append(self.create_block('heading_3', node.get_text(strip=True)))
- elif node.name == 'p':
- code_node = node.find('code')
- if code_node:
- code_text = code_node.get_text()
- language, code = self.extract_language_and_code(code_text)
- blocks.append(self.create_block('code', code, language=language))
- elif self.is_table(str(node)):
- blocks.extend(self.process_table(node))
- else:
- blocks.append(self.create_block('paragraph', node.get_text(strip=True)))
- elif node.name == 'ul':
- blocks.extend(self.process_list(node, 'bulleted_list_item'))
- elif node.name == 'ol':
- blocks.extend(self.process_list(node, 'numbered_list_item'))
- elif node.name == 'blockquote':
- blocks.append(self.create_block('quote', node.get_text(strip=True)))
- elif node.name == 'hr':
- blocks.append(self.create_block('divider', ''))
- elif node.name == 'img':
- blocks.append(self.create_block('image', '', image_url=node.get('src')))
- elif node.name == 'a':
- blocks.append(self.create_block('bookmark', node.get_text(strip=True), link_url=node.get('href')))
- elif node.name == 'table':
- blocks.extend(self.process_table(node))
-
- for child in node.children:
- if isinstance(child, str):
- continue
- blocks.extend(self.process_node(child))
-
- return blocks
-
- def extract_language_and_code(self, code_text):
- lines = code_text.split('\n')
- language = lines[0].strip()
- code = '\n'.join(lines[1:]).strip()
- return language, code
-
- def is_code_block(self, text):
- return text.startswith('```')
-
- def extract_code_block(self, text):
- lines = text.split('\n')
- language = lines[0].strip('`').strip()
- code = '\n'.join(lines[1:]).strip('`').strip()
- return language, code
-
- def is_table(self, text):
- rows = text.split('\n')
- if len(rows) < 2:
- return False
-
- has_separator = False
- for i, row in enumerate(rows):
- if '|' in row:
- cells = [cell.strip() for cell in row.split('|')]
- cells = [cell for cell in cells if cell] # Remove empty cells
- if i == 1 and all(set(cell) <= set('-|') for cell in cells):
- has_separator = True
- elif not cells:
- return False
-
- return has_separator and len(rows) >= 3
-
- def process_list(self, node, list_type):
- blocks = []
- for item in node.find_all('li'):
- item_text = item.get_text(strip=True)
- checked = item_text.startswith('[x]')
- is_checklist = item_text.startswith('[ ]') or checked
-
- if is_checklist:
- item_text = item_text.replace('[x]', '').replace('[ ]', '').strip()
- blocks.append(self.create_block('to_do', item_text, checked=checked))
- else:
- blocks.append(self.create_block(list_type, item_text))
- return blocks
-
- def process_table(self, node):
- blocks = []
- header_row = node.find('thead').find('tr') if node.find('thead') else None
- body_rows = node.find('tbody').find_all('tr') if node.find('tbody') else []
-
- if header_row or body_rows:
- table_width = max(len(header_row.find_all(['th', 'td'])) if header_row else 0,
- max(len(row.find_all(['th', 'td'])) for row in body_rows))
-
- table_block = self.create_block('table', '', table_width=table_width, has_column_header=bool(header_row))
- blocks.append(table_block)
-
- if header_row:
- header_cells = [cell.get_text(strip=True) for cell in header_row.find_all(['th', 'td'])]
- header_row_block = self.create_block('table_row', header_cells)
- blocks.append(header_row_block)
-
- for row in body_rows:
- cells = [cell.get_text(strip=True) for cell in row.find_all(['th', 'td'])]
- row_block = self.create_block('table_row', cells)
- blocks.append(row_block)
-
- return blocks
-
- def create_block(self, block_type: str, content: str, **kwargs) -> Dict[str, Any]:
- block = {
- "object": "block",
- "type": block_type,
- block_type: {},
- }
-
- if block_type in ["paragraph", "heading_1", "heading_2", "heading_3", "bulleted_list_item", "numbered_list_item", "quote"]:
- block[block_type]["rich_text"] = [
- {
- "type": "text",
- "text": {
- "content": content,
- },
- }
- ]
- elif block_type == 'to_do':
- block[block_type]["rich_text"] = [
- {
- "type": "text",
- "text": {
- "content": content,
- },
- }
- ]
- block[block_type]['checked'] = kwargs.get('checked', False)
- elif block_type == 'code':
- block[block_type]['rich_text'] = [
- {
- "type": "text",
- "text": {
- "content": content,
- },
- }
- ]
- block[block_type]['language'] = kwargs.get('language', 'plain text')
- elif block_type == 'image':
- block[block_type] = {
- "type": "external",
- "external": {
- "url": kwargs.get('image_url', '')
- }
- }
- elif block_type == 'divider':
- pass
- elif block_type == 'bookmark':
- block[block_type]['url'] = kwargs.get('link_url', '')
- elif block_type == 'table':
- block[block_type]['table_width'] = kwargs.get('table_width', 0)
- block[block_type]['has_column_header'] = kwargs.get('has_column_header', False)
- block[block_type]['has_row_header'] = kwargs.get('has_row_header', False)
- elif block_type == 'table_row':
- block[block_type]['cells'] = [[{'type': 'text', 'text': {'content': cell}} for cell in content]]
-
- return block
-```
-
-## Example Usage
-
-Example of using the `AddContentToPage` component in a Langflow flow using a Markdown as input:
-
-
-
-In this example, the `AddContentToPage` component connects to a `MarkdownLoader` component to provide the markdown text input. The converted Notion blocks are appended to the specified Notion page using the provided `block_id` and `notion_secret`.
-
-## Best Practices
-
-When using the `AddContentToPage` component:
-
-- Ensure markdown text is well-formatted.
-- Verify the `block_id` corresponds to the right Notion page/block.
-- Keep your Notion integration token secure.
-- Test with sample markdown text before production use.
-
-## Troubleshooting
-
-If issues arise:
-
-- Verify the Notion integration token’s validity and permissions.
-- Check the Notion API documentation for updates.
-- Ensure markdown text is properly formatted.
-- Double-check the `block_id` for correctness.
-
-The `AddContentToPage` component is a powerful tool for integrating Notion content creation into Langflow workflows, facilitating easy conversion of markdown text to Notion blocks and appending them to specific pages.
diff --git a/docs/docs/integrations/notion/notion-page-content-viewer.md b/docs/docs/integrations/notion/page-content-viewer.md
similarity index 94%
rename from docs/docs/integrations/notion/notion-page-content-viewer.md
rename to docs/docs/integrations/notion/page-content-viewer.md
index ac5127721..c8b23b05d 100644
--- a/docs/docs/integrations/notion/notion-page-content-viewer.md
+++ b/docs/docs/integrations/notion/page-content-viewer.md
@@ -7,6 +7,8 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
Langflow allows you to extend its functionality with custom components. The `NotionPageContent` component is designed to retrieve the content of a Notion page as plain text. It provides a convenient way to integrate Notion page content into your Langflow workflows.
+[Notion Reference](https://developers.notion.com/reference/get-page)
+
> **Component Functionality**
>
> The `NotionPageContent` component enables you to:
@@ -30,13 +32,15 @@ Here's the code block for the `NotionPageContent` component:
```python
import requests
from typing import Dict, Any
+
from langflow import CustomComponent
from langflow.schema import Record
+
class NotionPageContent(CustomComponent):
display_name = "Page Content Viewer [Notion]"
description = "Retrieve the content of a Notion page as plain text."
- documentation: str = "https://developers.notion.com/reference/get-page"
+ documentation: str = "https://docs.langflow.org/integrations/notion/page-content-viewer"
icon = "NotionDirectoryLoader"
def build_config(self):
@@ -54,18 +58,25 @@ class NotionPageContent(CustomComponent):
},
}
- def build(self, page_id: str, notion_secret: str) -> Record:
+ def build(
+ self,
+ page_id: str,
+ notion_secret: str,
+ ) -> Record:
blocks_url = f"https://api.notion.com/v1/blocks/{page_id}/children?page_size=100"
headers = {
"Authorization": f"Bearer {notion_secret}",
- "Notion-Version": "2022-06-28", # Use the latest supported version
+ "Notion-Version": "2022-06-28", # Use the latest supported version
}
+
# Retrieve the child blocks
blocks_response = requests.get(blocks_url, headers=headers)
blocks_response.raise_for_status()
blocks_data = blocks_response.json()
+
# Parse the blocks and extract the content as plain text
content = self.parse_blocks(blocks_data["results"])
+
self.status = content
return Record(data={"content": content}, text=content)
diff --git a/docs/docs/integrations/notion/notion-page-create.md b/docs/docs/integrations/notion/page-create.md
similarity index 91%
rename from docs/docs/integrations/notion/notion-page-create.md
rename to docs/docs/integrations/notion/page-create.md
index 62fc049a7..aeb10354b 100644
--- a/docs/docs/integrations/notion/notion-page-create.md
+++ b/docs/docs/integrations/notion/page-create.md
@@ -7,6 +7,8 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
Langflow allows you to extend its functionality with custom components. The `NotionPageCreator` component is designed to create pages in a Notion database. It provides a convenient way to integrate Notion page creation into your Langflow workflows.
+[Notion Reference](https://developers.notion.com/reference/patch-block-children)
+
The `NotionPageCreator` component enables you to:
- Create new pages in a specified Notion database
@@ -29,10 +31,17 @@ To use the `NotionPageCreator` component in a Langflow flow, follow these steps:
Here's the code block for the `NotionPageCreator` component:
```python
+import json
+from typing import Optional
+
+import requests
+from langflow.custom import CustomComponent
+
+
class NotionPageCreator(CustomComponent):
display_name = "Create Page [Notion]"
description = "A component for creating Notion pages."
- documentation: str = "https://developers.notion.com/reference/post-database-query"
+ documentation: str = "https://docs.langflow.org/integrations/notion/page-create"
icon = "NotionDirectoryLoader"
def build_config(self):
@@ -60,7 +69,7 @@ class NotionPageCreator(CustomComponent):
database_id: str,
notion_secret: str,
properties: str = '{"Task name": {"id": "title", "type": "title", "title": [{"type": "text", "text": {"content": "Send Notion Components to LF", "link": null}}]}}',
- ) -> Record:
+ ) -> str:
if not database_id or not properties:
raise ValueError("Invalid input. Please provide 'database_id' and 'properties'.")
@@ -74,22 +83,17 @@ class NotionPageCreator(CustomComponent):
"parent": {"database_id": database_id},
"properties": json.loads(properties),
}
-
+
response = requests.post("https://api.notion.com/v1/pages", headers=headers, json=data)
if response.status_code == 200:
- response = response.json()
- page_id = response["id"]
- page_url = response["url"]
- return_message = f"Successfully created Notion page with ID: {page_id}\n Page URL: {page_url}"
- self.status=return_message
-
- return Record(text=return_message, page_id=page_id, url=page_url)
+ page_id = response.json()["id"]
+ self.status = f"Successfully created Notion page with ID: {page_id}\n {str(response.json())}"
+ return response.json()
else:
error_message = f"Failed to create Notion page. Status code: {response.status_code}, Error: {response.text}"
self.status = error_message
raise Exception(error_message)
- return Record(text="Not able to connect to notion")
```
diff --git a/docs/docs/integrations/notion/notion-page-update.md b/docs/docs/integrations/notion/page-update.md
similarity index 96%
rename from docs/docs/integrations/notion/notion-page-update.md
rename to docs/docs/integrations/notion/page-update.md
index 9e8e8efa3..87c6ba63c 100644
--- a/docs/docs/integrations/notion/notion-page-update.md
+++ b/docs/docs/integrations/notion/page-update.md
@@ -7,6 +7,8 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
Langflow allows you to extend its functionality with custom components. The `NotionPageUpdate` component is designed to update the properties of a Notion page. It provides a convenient way to integrate updating Notion page properties into your Langflow workflows.
+[Notion Reference](https://developers.notion.com/reference/patch-page)
+
## Component Usage
To use the `NotionPageUpdate` component in your Langflow flow:
@@ -22,16 +24,15 @@ Here's the code for the `NotionPageUpdate` component:
import json
import requests
from typing import Dict, Any
-from loguru import logger
-from langflow.custom import CustomComponent
+from langflow import CustomComponent
from langflow.schema import Record
class NotionPageUpdate(CustomComponent):
display_name = "Update Page Property [Notion]"
description = "Update the properties of a Notion page."
- documentation: str = "https://developers.notion.com/reference/patch-page"
+ documentation: str = "https://docs.langflow.org/integrations/notion/page-update"
icon = "NotionDirectoryLoader"
def build_config(self):
@@ -76,7 +77,7 @@ class NotionPageUpdate(CustomComponent):
data = {
"properties": parsed_properties
}
-
+
response = requests.patch(url, headers=headers, json=data)
response.raise_for_status()
diff --git a/docs/docs/integrations/notion/notion-search.md b/docs/docs/integrations/notion/search.md
similarity index 98%
rename from docs/docs/integrations/notion/notion-search.md
rename to docs/docs/integrations/notion/search.md
index f9bfb054a..34971412a 100644
--- a/docs/docs/integrations/notion/notion-search.md
+++ b/docs/docs/integrations/notion/search.md
@@ -7,6 +7,8 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
Langflow allows you to extend its functionality with custom components. The `NotionSearch` component is designed to search all pages and databases that have been shared with an integration in Notion. It provides a convenient way to integrate Notion search capabilities into your Langflow workflows.
+[Notion Reference](https://developers.notion.com/reference/search)
+
> **Tip**:
>
> ### Component Functionality
@@ -42,7 +44,7 @@ class NotionSearch(CustomComponent):
description = (
"Searches all pages and databases that have been shared with an integration."
)
- documentation: str = "https://developers.notion.com/reference/search"
+ documentation: str = "https://docs.langflow.org/integrations/notion/search"
icon = "NotionDirectoryLoader"
field_order = [
diff --git a/docs/docs/integrations/notion/notion-setup.md b/docs/docs/integrations/notion/setup.md
similarity index 100%
rename from docs/docs/integrations/notion/notion-setup.md
rename to docs/docs/integrations/notion/setup.md
diff --git a/docs/sidebars.js b/docs/sidebars.js
index 5832a36c8..ef13eacb2 100644
--- a/docs/sidebars.js
+++ b/docs/sidebars.js
@@ -140,15 +140,15 @@ module.exports = {
type: "category",
label: "Notion",
items: [
- "integrations/notion/notion-setup",
- "integrations/notion/notion-search",
- "integrations/notion/notion-list-database-properties",
- "integrations/notion/notion-list-pages",
- "integrations/notion/notion-list-users",
- "integrations/notion/notion-page-create",
- "integrations/notion/notion-add-content-to-page",
- "integrations/notion/notion-page-update",
- "integrations/notion/notion-page-content-viewer",
+ "integrations/notion/setup",
+ "integrations/notion/search",
+ "integrations/notion/list-database-properties",
+ "integrations/notion/list-pages",
+ "integrations/notion/list-users",
+ "integrations/notion/page-create",
+ "integrations/notion/add-content-to-page",
+ "integrations/notion/page-update",
+ "integrations/notion/page-content-viewer",
],
},
],