docs: fix notion docs and move to integrations folder
This commit is contained in:
parent
6ef23325e1
commit
1b81f6d6ef
9 changed files with 8 additions and 8 deletions
|
|
@ -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";
|
||||
|
||||
# AddContentToPage Component in Langflow
|
||||
|
||||
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:
|
||||
|
||||
<ZoomableImage
|
||||
alt="NotionDatabaseProperties Flow Example"
|
||||
sources={{
|
||||
light: "img/notion/AddContentToPage_flow_example.png",
|
||||
dark: "img/notion/AddContentToPage_flow_example.png",
|
||||
}}
|
||||
style={{ width: "100%", margin: "20px 0" }}
|
||||
/>
|
||||
|
||||
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.
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
import Admonition from "@theme/Admonition";
|
||||
import ThemedImage from "@theme/ThemedImage";
|
||||
import useBaseUrl from "@docusaurus/useBaseUrl";
|
||||
import ZoomableImage from "/src/theme/ZoomableImage.js";
|
||||
|
||||
# NotionDatabaseProperties Component in Langflow
|
||||
|
||||
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.
|
||||
|
||||
<Admonition type="tip" title="Component Functionality">
|
||||
The `NotionDatabaseProperties` component enables you to:
|
||||
- Retrieve properties of a Notion database
|
||||
- Access the retrieved properties in your Langflow flows
|
||||
- Integrate Notion database information seamlessly into your workflows
|
||||
</Admonition>
|
||||
|
||||
## Component Usage
|
||||
|
||||
To use the `NotionDatabaseProperties` component in a Langflow flow, follow these steps:
|
||||
|
||||
1. Add the `NotionDatabaseProperties` component to your flow.
|
||||
2. Configure the component by providing the required inputs:
|
||||
- `database_id`: The ID of the Notion database you want to retrieve properties from.
|
||||
- `notion_secret`: The Notion integration token for authentication.
|
||||
3. Connect the output of the `NotionDatabaseProperties` component to other components in your flow as needed.
|
||||
|
||||
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"
|
||||
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,
|
||||
},
|
||||
}
|
||||
|
||||
def build(
|
||||
self,
|
||||
database_id: str,
|
||||
notion_secret: str,
|
||||
) -> Record:
|
||||
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
|
||||
}
|
||||
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}"
|
||||
return record
|
||||
```
|
||||
|
||||
<Admonition type="info" title="Example Usage">
|
||||
Here's an example of how you can use the `NotionDatabaseProperties` component in a Langflow flow:
|
||||
|
||||
<ZoomableImage
|
||||
alt="NotionDatabaseProperties Flow Example"
|
||||
sources={{
|
||||
light: "img/notion/NotionDatabaseProperties_flow_example.png",
|
||||
dark: "img/notion/NotionDatabaseProperties_flow_example_dark.png",
|
||||
}}
|
||||
style={{ width: "100%", margin: "20px 0" }}
|
||||
/>
|
||||
|
||||
In this example, the `NotionDatabaseProperties` component retrieves the properties of a Notion database, and the retrieved properties are then used as input for subsequent components in the flow.
|
||||
</Admonition>
|
||||
|
||||
## Best Practices
|
||||
|
||||
<Admonition type="tip" title="Best Practices">
|
||||
When using the `NotionDatabaseProperties` component, consider the following best practices:
|
||||
- Ensure that you have a valid Notion integration token with the necessary permissions to access the desired database.
|
||||
- Double-check the database ID to avoid retrieving properties from the wrong database.
|
||||
- Handle potential errors gracefully by checking the response status and providing appropriate error messages.
|
||||
</Admonition>
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
<Admonition type="warning" title="Troubleshooting">
|
||||
If you encounter any issues while using the `NotionDatabaseProperties` component, consider the following:
|
||||
- Verify that the Notion integration token is valid and has the required permissions.
|
||||
- Check the database ID to ensure it matches the intended Notion database.
|
||||
- Inspect the response from the Notion API for any error messages or status codes that may indicate the cause of the issue.
|
||||
</Admonition>
|
||||
|
||||
The `NotionDatabaseProperties` component simplifies the process of retrieving properties from a Notion database and integrating them into your Langflow workflows. By leveraging this component, you can easily access and utilize Notion database information in your flows, enabling powerful integrations and automations.
|
||||
|
||||
Feel free to explore the capabilities of the `NotionDatabaseProperties` component and experiment with different use cases to enhance your Langflow workflows!
|
||||
|
|
@ -1,156 +0,0 @@
|
|||
import Admonition from "@theme/Admonition";
|
||||
import ThemedImage from "@theme/ThemedImage";
|
||||
import useBaseUrl from "@docusaurus/useBaseUrl";
|
||||
import ZoomableImage from "/src/theme/ZoomableImage.js";
|
||||
|
||||
# NotionDatabaseQuery Component in Langflow
|
||||
|
||||
Langflow allows you to extend its functionality with custom components. The `NotionDatabaseQuery` 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.
|
||||
|
||||
> **Tip**:
|
||||
>
|
||||
> ### Component Functionality
|
||||
>
|
||||
> The `NotionDatabaseQuery` component enables you to:
|
||||
>
|
||||
> - Query a Notion database with custom filters and sorting options
|
||||
> - Retrieve specific pages from a Notion database based on the provided criteria
|
||||
> - Integrate Notion database data seamlessly into your Langflow workflows
|
||||
|
||||
## Component Usage
|
||||
|
||||
To use the `NotionDatabaseQuery` component in a Langflow flow, follow these steps:
|
||||
|
||||
1. **Add the `NotionDatabaseQuery` component to your flow.**
|
||||
2. **Configure the component by providing the required parameters:**
|
||||
- `notion_secret`: The Notion integration token for authentication.
|
||||
- `database_id`: The ID of the Notion database you want to query.
|
||||
- `query_payload`: A JSON string containing the filters and sorting options for the query.
|
||||
3. **Connect the `NotionDatabaseQuery` component to other components in your flow as needed.**
|
||||
|
||||
### Example Component Code
|
||||
|
||||
```python
|
||||
import requests
|
||||
from typing import Dict, Any
|
||||
from langchain.agents import Tool
|
||||
|
||||
from langflow.base.tools.base import build_status_from_tool
|
||||
from langflow.custom import CustomComponent
|
||||
|
||||
|
||||
class NotionDatabaseQuery(CustomComponent):
|
||||
display_name = "List Pages [Notion]"
|
||||
description = (
|
||||
"Query a Notion database with filtering and sorting. "
|
||||
"The input should be a JSON string containing the 'filter' and 'sorts' objects. "
|
||||
"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"
|
||||
icon = "NotionDirectoryLoader"
|
||||
|
||||
def build_config(self):
|
||||
return {
|
||||
"notion_secret": {
|
||||
"display_name": "Notion Secret",
|
||||
"field_type": "str",
|
||||
"info": "The Notion integration token.",
|
||||
"password": True,
|
||||
},
|
||||
"database_id": {
|
||||
"display_name": "Database ID",
|
||||
"field_type": "str",
|
||||
"info": "The ID of the Notion database to query.",
|
||||
},
|
||||
"query_payload": {
|
||||
"display_name": "Database query",
|
||||
"field_type": "str",
|
||||
"info": "A JSON string containing the filters that will be used for querying the database. EG: {'filter': {'property': 'Status', 'status': {'equals': 'In progress'}}}",
|
||||
},
|
||||
}
|
||||
|
||||
def build(
|
||||
self,
|
||||
notion_secret: str,
|
||||
database_id: str,
|
||||
query_payload: str,
|
||||
) -> str:
|
||||
try:
|
||||
query_data = json.loads(query_payload)
|
||||
filter_obj = query_data.get("filter")
|
||||
sorts = query_data.get("sorts", [])
|
||||
|
||||
url = f"https://api.notion.com/v1/databases/{database_id}/query"
|
||||
headers = {
|
||||
"Authorization": f"Bearer {notion_secret}",
|
||||
"Content-Type": "application/json",
|
||||
"Notion-Version": "2022-06-28",
|
||||
}
|
||||
|
||||
data = {
|
||||
"sorts": sorts,
|
||||
}
|
||||
|
||||
if filter_obj:
|
||||
data["filter"] = filter_obj
|
||||
|
||||
response = requests.post(url, headers=headers, json=data)
|
||||
response.raise_for_status()
|
||||
|
||||
results = response.json()
|
||||
output = f"Pages found: {len(results['results'])}\n\n"
|
||||
for page in results["results"]:
|
||||
output += f"Page ID: {page['id']}\n"
|
||||
output += f"Page URL: {page['url']}\n"
|
||||
output += f"Created At: {page['created_time']}\n"
|
||||
output += f"Updated At: {page['last_edited_time']}\n"
|
||||
output += f"Properties: {json.dumps(page['properties'], indent=2)}\n\n"
|
||||
|
||||
return output
|
||||
|
||||
except Exception as e:
|
||||
return f"An error occurred: {str(e)}"
|
||||
```
|
||||
|
||||
## Example Usage
|
||||
|
||||
Here's an example of how you can use the `NotionDatabaseQuery` component in a Langflow flow and passing to the Prompt component:
|
||||
|
||||
<ZoomableImage
|
||||
alt="NotionDatabaseQuery Flow Example"
|
||||
sources={{
|
||||
light: "img/notion/NotionDatabaseQuery_flow_example.png",
|
||||
dark: "img/notion/NotionDatabaseQuery_flow_example_dark.png",
|
||||
}}
|
||||
style={{ width: "100%", margin: "20px 0" }}
|
||||
/>
|
||||
|
||||
In this example, the `NotionDatabaseQuery` component is used to retrieve specific pages from a Notion database based on the provided filters and sorting options. The retrieved data can then be processed further in the subsequent components of the flow.
|
||||
|
||||
## Best Practices
|
||||
|
||||
> **Tip**:
|
||||
>
|
||||
> ### Best Practices
|
||||
>
|
||||
> When using the `NotionDatabaseQuery` component, consider the following best practices:
|
||||
>
|
||||
> - Ensure that you have a valid Notion integration token with the necessary permissions to query the desired database.
|
||||
> - Construct the `query_payload` JSON string carefully, following the Notion API documentation for filtering and sorting options.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
> **Warning**:
|
||||
>
|
||||
> ### Troubleshooting
|
||||
>
|
||||
> If you encounter any issues while using the `NotionDatabaseQuery` component, consider the following:
|
||||
>
|
||||
> - Double-check that the `notion_secret` and `database_id` are correct and valid.
|
||||
> - Verify that the `query_payload` JSON string is properly formatted and contains valid filtering and sorting options.
|
||||
> - Check the Notion API documentation for any updates or changes that may affect the component's functionality.
|
||||
|
||||
The `NotionDatabaseQuery` component provides a powerful way to integrate Notion database querying capabilities into your Langflow workflows. By leveraging this component, you can easily retrieve specific pages from a Notion database based on custom filters and sorting options, enabling you to build more dynamic and data-driven flows.
|
||||
|
||||
We encourage you to explore the capabilities of the `NotionDatabaseQuery` component further and experiment with different querying scenarios to unlock the full potential of integrating Notion databases into your Langflow workflows.
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
import Admonition from "@theme/Admonition";
|
||||
import ThemedImage from "@theme/ThemedImage";
|
||||
import useBaseUrl from "@docusaurus/useBaseUrl";
|
||||
import ZoomableImage from "/src/theme/ZoomableImage.js";
|
||||
|
||||
# NotionUserList Component in Langflow
|
||||
|
||||
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.
|
||||
|
||||
> **Component Functionality**
|
||||
>
|
||||
> The `NotionUserList` component enables you to:
|
||||
>
|
||||
> - Retrieve user data from Notion
|
||||
> - Access user information such as ID, type, name, and avatar URL
|
||||
> - Integrate Notion user data seamlessly into your Langflow workflows
|
||||
|
||||
## Component Usage
|
||||
|
||||
To use the `NotionUserList` component in a Langflow flow, follow these steps:
|
||||
|
||||
1. Add the `NotionUserList` component to your flow.
|
||||
2. Configure the component by providing the required Notion secret token.
|
||||
3. Connect the component to other nodes in your flow as needed.
|
||||
|
||||
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"
|
||||
icon = "NotionDirectoryLoader"
|
||||
|
||||
def build_config(self):
|
||||
return {
|
||||
"notion_secret": {
|
||||
"display_name": "Notion Secret",
|
||||
"field_type": "str",
|
||||
"info": "The Notion integration token.",
|
||||
"password": True,
|
||||
},
|
||||
}
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
> **Example Usage**
|
||||
>
|
||||
> Here's an example of how you can use the `NotionUserList` component in a Langflow flow and passing the outputs to the Prompt component:
|
||||
|
||||
<ZoomableImage
|
||||
alt="NotionUserList Flow Example"
|
||||
sources={{
|
||||
light: "img/NotionUserList_flow_example.png",
|
||||
dark: "img/NotionUserList_flow_example_dark.png",
|
||||
}}
|
||||
style={{ width: "100%", margin: "20px 0" }}
|
||||
/>
|
||||
|
||||
## Best Practices
|
||||
|
||||
> **Best Practices**
|
||||
>
|
||||
> When using the `NotionUserList` component, consider the following best practices:
|
||||
>
|
||||
> - Ensure that you have a valid Notion integration token with the necessary permissions to retrieve user data.
|
||||
> - Handle the retrieved user data securely and in compliance with Notion's API usage guidelines.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
> **Troubleshooting**
|
||||
>
|
||||
> If you encounter any issues while using the `NotionUserList` component, consider the following:
|
||||
>
|
||||
> - Double-check that your Notion integration token is valid and has the required permissions.
|
||||
> - Verify that you have installed the necessary dependencies (`requests`) for the component to function properly.
|
||||
> - Check the Notion API documentation for any updates or changes that may affect the component's functionality.
|
||||
|
||||
The `NotionUserList` component provides a seamless way to integrate Notion user data into your Langflow workflows. By leveraging this component, you can easily retrieve and utilize user information from Notion, enhancing the capabilities of your Langflow applications. Feel free to explore and experiment with the `NotionUserList` component to unlock new possibilities in your Langflow projects!
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
import Admonition from "@theme/Admonition";
|
||||
import ThemedImage from "@theme/ThemedImage";
|
||||
import useBaseUrl from "@docusaurus/useBaseUrl";
|
||||
import ZoomableImage from "/src/theme/ZoomableImage.js";
|
||||
|
||||
# NotionPageContent Component in Langflow
|
||||
|
||||
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.
|
||||
|
||||
> **Component Functionality**
|
||||
>
|
||||
> The `NotionPageContent` component enables you to:
|
||||
>
|
||||
> - Retrieve the content of a Notion page as plain text
|
||||
> - Extract text from various block types, including paragraphs, headings, lists, and more
|
||||
> - Integrate Notion page content seamlessly into your Langflow workflows
|
||||
|
||||
## Component Usage
|
||||
|
||||
To use the `NotionPageContent` component in a Langflow flow, follow these steps:
|
||||
|
||||
1. Add the `NotionPageContent` component to your flow.
|
||||
2. Configure the component by providing the required inputs:
|
||||
- `page_id`: The ID of the Notion page you want to retrieve.
|
||||
- `notion_secret`: Your Notion integration token for authentication.
|
||||
3. Connect the output of the `NotionPageContent` component to other components in your flow as needed.
|
||||
|
||||
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"
|
||||
icon = "NotionDirectoryLoader"
|
||||
|
||||
def build_config(self):
|
||||
return {
|
||||
"page_id": {
|
||||
"display_name": "Page ID",
|
||||
"field_type": "str",
|
||||
"info": "The ID of the Notion page to retrieve.",
|
||||
},
|
||||
"notion_secret": {
|
||||
"display_name": "Notion Secret",
|
||||
"field_type": "str",
|
||||
"info": "The Notion integration token.",
|
||||
"password": True,
|
||||
},
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
# 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)
|
||||
|
||||
def parse_blocks(self, blocks: list) -> str:
|
||||
content = ""
|
||||
for block in blocks:
|
||||
block_type = block["type"]
|
||||
if block_type in ["paragraph", "heading_1", "heading_2", "heading_3", "quote"]:
|
||||
content += self.parse_rich_text(block[block_type]["rich_text"]) + "\n\n"
|
||||
elif block_type in ["bulleted_list_item", "numbered_list_item"]:
|
||||
content += self.parse_rich_text(block[block_type]["rich_text"]) + "\n"
|
||||
elif block_type == "to_do":
|
||||
content += self.parse_rich_text(block["to_do"]["rich_text"]) + "\n"
|
||||
elif block_type == "code":
|
||||
content += self.parse_rich_text(block["code"]["rich_text"]) + "\n\n"
|
||||
elif block_type == "image":
|
||||
content += f"[Image: {block['image']['external']['url']}]\n\n"
|
||||
elif block_type == "divider":
|
||||
content += "---\n\n"
|
||||
return content.strip()
|
||||
|
||||
def parse_rich_text(self, rich_text: list) -> str:
|
||||
text = ""
|
||||
for segment in rich_text:
|
||||
text += segment["plain_text"]
|
||||
return text
|
||||
```
|
||||
|
||||
> **Example Usage**
|
||||
>
|
||||
> Here's an example of how you can use the `NotionPageContent` component in a Langflow flow:
|
||||
|
||||
<ZoomableImage
|
||||
alt="NotionPageContent Flow Example"
|
||||
sources={{
|
||||
light: "img/notion/NotionPageContent_flow_example.png",
|
||||
dark: "img/notion/NotionPageContent_flow_example_dark.png",
|
||||
}}
|
||||
style={{ width: "100%", margin: "20px 0" }}
|
||||
/>
|
||||
|
||||
## Best Practices
|
||||
|
||||
> **Best Practices**
|
||||
>
|
||||
> When using the `NotionPageContent` component, consider the following best practices:
|
||||
>
|
||||
> - Ensure that you have the necessary permissions to access the Notion page you want to retrieve.
|
||||
> - Keep your Notion integration token secure and avoid sharing it publicly.
|
||||
> - Be mindful of the content you retrieve and ensure that it aligns with your intended use case.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
> **Troubleshooting**
|
||||
>
|
||||
> If you encounter any issues while using the `NotionPageContent` component, consider the following:
|
||||
>
|
||||
> - Double-check that you have provided the correct Notion page ID.
|
||||
> - Verify that your Notion integration token is valid and has the necessary permissions.
|
||||
> - Check the Notion API documentation for any updates or changes that may affect the component's functionality.
|
||||
|
||||
The `NotionPageContent` component provides a seamless way to integrate Notion page content into your Langflow workflows. By leveraging this component, you can easily retrieve and process the content of Notion pages, enabling you to build powerful and dynamic applications. Explore the capabilities of the `NotionPageContent` component and unlock new possibilities in your Langflow projects!
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
import Admonition from "@theme/Admonition";
|
||||
import ThemedImage from "@theme/ThemedImage";
|
||||
import useBaseUrl from "@docusaurus/useBaseUrl";
|
||||
import ZoomableImage from "/src/theme/ZoomableImage.js";
|
||||
|
||||
# NotionPageCreator Component in Langflow
|
||||
|
||||
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.
|
||||
|
||||
<Admonition type="tip" title="Component Functionality">
|
||||
The `NotionPageCreator` component enables you to:
|
||||
- Create new pages in a specified Notion database
|
||||
- Set custom properties for the created pages
|
||||
- Retrieve the ID and URL of the newly created pages
|
||||
</Admonition>
|
||||
|
||||
## Component Usage
|
||||
|
||||
To use the `NotionPageCreator` component in a Langflow flow, follow these steps:
|
||||
|
||||
1. Add the `NotionPageCreator` component to your flow.
|
||||
2. Configure the component by providing the required inputs:
|
||||
- `database_id`: The ID of the Notion database where the pages will be created.
|
||||
- `notion_secret`: The Notion integration token for authentication.
|
||||
- `properties`: The properties of the new page, specified as a JSON string.
|
||||
3. Connect the component to other components in your flow as needed.
|
||||
4. Run the flow to create Notion pages based on the configured inputs.
|
||||
|
||||
Here's the code block for the `NotionPageCreator` component:
|
||||
|
||||
```python
|
||||
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"
|
||||
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}}]}}',
|
||||
) -> Record:
|
||||
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:
|
||||
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)
|
||||
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")
|
||||
```
|
||||
|
||||
<Admonition type="info" title="Example Usage">
|
||||
Here's an example of how to use the `NotionPageCreator` component in a Langflow flow:
|
||||
|
||||
<ZoomableImage
|
||||
alt="NotionPageCreator Flow Example"
|
||||
sources={{
|
||||
light: "img/NotionPageCreator_flow_example.png",
|
||||
dark: "img/NotionPageCreator_flow_example_dark.png",
|
||||
}}
|
||||
style={{ width: "100%", margin: "20px 0" }}
|
||||
/>
|
||||
</Admonition>
|
||||
|
||||
## Best Practices
|
||||
|
||||
<Admonition type="tip" title="Best Practices">
|
||||
When using the `NotionPageCreator` component, consider the following best practices:
|
||||
- Ensure that you have a valid Notion integration token with the necessary permissions to create pages in the specified database.
|
||||
- Properly format the `properties` input as a JSON string, matching the structure and field types of your Notion database.
|
||||
- Handle any errors or exceptions that may occur during the page creation process and provide appropriate error messages.
|
||||
- To avoid the hassle of messing with JSON, we recommend using the LLM to create the JSON for you as input.
|
||||
|
||||
</Admonition>
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
<Admonition type="warning" title="Troubleshooting">
|
||||
If you encounter any issues while using the `NotionPageCreator` component, consider the following:
|
||||
- Double-check that the `database_id` and `notion_secret` inputs are correct and valid.
|
||||
- Verify that the `properties` input is properly formatted as a JSON string and matches the structure of your Notion database.
|
||||
- Check the Notion API documentation for any updates or changes that may affect the component's functionality.
|
||||
</Admonition>
|
||||
|
||||
The `NotionPageCreator` component simplifies the process of creating pages in a Notion database directly from your Langflow workflows. By leveraging this component, you can seamlessly integrate Notion page creation functionality into your automated processes, saving time and effort. Feel free to explore the capabilities of the `NotionPageCreator` component and adapt it to suit your specific requirements.
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
import Admonition from "@theme/Admonition";
|
||||
import ThemedImage from "@theme/ThemedImage";
|
||||
import useBaseUrl from "@docusaurus/useBaseUrl";
|
||||
import ZoomableImage from "/src/theme/ZoomableImage.js";
|
||||
|
||||
# NotionPageUpdate Component in Langflow
|
||||
|
||||
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.
|
||||
|
||||
## Component Usage
|
||||
|
||||
To use the `NotionPageUpdate` component in your Langflow flow:
|
||||
|
||||
1. Drag and drop the `NotionPageUpdate` component onto the canvas.
|
||||
2. Double-click the component to open its configuration.
|
||||
3. Provide the required parameters as defined in the component's `build_config` method.
|
||||
4. Connect the component to other nodes in your flow as needed.
|
||||
|
||||
Here's the code for the `NotionPageUpdate` component:
|
||||
|
||||
```python
|
||||
import json
|
||||
import requests
|
||||
from typing import Dict, Any
|
||||
from loguru import logger
|
||||
|
||||
from langflow.custom 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"
|
||||
icon = "NotionDirectoryLoader"
|
||||
|
||||
def build_config(self):
|
||||
return {
|
||||
"page_id": {
|
||||
"display_name": "Page ID",
|
||||
"field_type": "str",
|
||||
"info": "The ID of the Notion page to update.",
|
||||
},
|
||||
"properties": {
|
||||
"display_name": "Properties",
|
||||
"field_type": "str",
|
||||
"info": "The properties to update on the page (as a JSON string).",
|
||||
"multiline": True,
|
||||
},
|
||||
"notion_secret": {
|
||||
"display_name": "Notion Secret",
|
||||
"field_type": "str",
|
||||
"info": "The Notion integration token.",
|
||||
"password": True,
|
||||
},
|
||||
}
|
||||
|
||||
def build(
|
||||
self,
|
||||
page_id: str,
|
||||
properties: str,
|
||||
notion_secret: str,
|
||||
) -> Record:
|
||||
url = f"https://api.notion.com/v1/pages/{page_id}"
|
||||
headers = {
|
||||
"Authorization": f"Bearer {notion_secret}",
|
||||
"Content-Type": "application/json",
|
||||
"Notion-Version": "2022-06-28", # Use the latest supported version
|
||||
}
|
||||
|
||||
try:
|
||||
parsed_properties = json.loads(properties)
|
||||
except json.JSONDecodeError as e:
|
||||
raise ValueError("Invalid JSON format for properties") from e
|
||||
|
||||
data = {
|
||||
"properties": parsed_properties
|
||||
}
|
||||
|
||||
response = requests.patch(url, headers=headers, json=data)
|
||||
response.raise_for_status()
|
||||
|
||||
updated_page = response.json()
|
||||
|
||||
output = "Updated page properties:\n"
|
||||
for prop_name, prop_value in updated_page["properties"].items():
|
||||
output += f"{prop_name}: {prop_value}\n"
|
||||
|
||||
self.status = output
|
||||
return Record(data=updated_page)
|
||||
```
|
||||
|
||||
Let's break down the key parts of this component:
|
||||
|
||||
- The `build_config` method defines the configuration fields for the component. It specifies the required parameters and their properties, such as display names, field types, and any additional information or validation.
|
||||
|
||||
- The `build` method contains the main logic of the component. It takes the configured parameters as input and performs the necessary operations to update the properties of a Notion page.
|
||||
|
||||
- The component interacts with the Notion API to update the page properties. It constructs the API URL, headers, and request data based on the provided parameters.
|
||||
|
||||
- The processed data is returned as a `Record` object, which can be connected to other components in the Langflow flow. The `Record` object contains the updated page data.
|
||||
|
||||
- The component also stores the updated page properties in the `status` attribute for logging and debugging purposes.
|
||||
|
||||
<Admonition type="info" title="Example Usage">
|
||||
Here's an example of how to use the `NotionPageUpdate` component in a Langflow flow using:
|
||||
|
||||
<ZoomableImage
|
||||
alt="NotionPageUpdate Flow Example"
|
||||
sources={{
|
||||
light: "img/notion/NotionPageUpdate_flow_example.png",
|
||||
dark: "img/notion/NotionPageUpdate_flow_example_dark.png",
|
||||
}}
|
||||
style={{ width: "100%", margin: "20px 0" }}
|
||||
/>
|
||||
</Admonition>
|
||||
|
||||
## Best Practices
|
||||
|
||||
When using the `NotionPageUpdate` component, consider the following best practices:
|
||||
|
||||
- Ensure that you have a valid Notion integration token with the necessary permissions to update page properties.
|
||||
- Handle edge cases and error scenarios gracefully, such as invalid JSON format for properties or API request failures.
|
||||
- We recommend using an LLM to generate the inputs for this component, to allow flexibilty
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If you encounter any issues while using the `NotionPageUpdate` component, consider the following:
|
||||
|
||||
- Double-check that you have correctly configured the component with the required parameters, including the page ID, properties JSON, and Notion integration token.
|
||||
- Verify that your Notion integration token has the necessary permissions to update page properties.
|
||||
- Check the Langflow logs for any error messages or exceptions related to the component, such as invalid JSON format or API request failures.
|
||||
- Consult the [Notion API Documentation](https://developers.notion.com/reference/patch-page) for specific troubleshooting steps or common issues related to updating page properties.
|
||||
|
||||
By leveraging the `NotionPageUpdate` component in Langflow, you can easily integrate updating Notion page properties into your language model workflows and build powerful applications that extend Langflow's capabilities.
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
import Admonition from "@theme/Admonition";
|
||||
|
||||
# Setting up a Notion Integration for Langflow
|
||||
|
||||
To use Notion components in Langflow, you first need to create a Notion integration and configure it with the necessary capabilities. This guide will walk you through the process of setting up a Notion integration and granting it access to your Notion databases.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- A Notion account with access to the workspace where you want to use the integration.
|
||||
- Admin permissions in the Notion workspace to create and manage integrations.
|
||||
|
||||
## Step 1: Create a Notion Integration
|
||||
|
||||
1. Go to the [Notion Integrations](https://www.notion.com/my-integrations) page.
|
||||
2. Click on the "New integration" button.
|
||||
3. Give your integration a name and select the workspace where you want to use it.
|
||||
4. Click "Submit" to create the integration.
|
||||
|
||||
<Admonition type="info" title="Integration Capabilities">
|
||||
When creating the integration, make sure to enable the necessary capabilities based on your requirements. Refer to the [Notion Integration Capabilities](https://developers.notion.com/reference/capabilities) documentation for more information on each capability.
|
||||
</Admonition>
|
||||
|
||||
## Step 2: Configure Integration Capabilities
|
||||
|
||||
After creating the integration, you need to configure its capabilities to define what actions it can perform and what data it can access.
|
||||
|
||||
1. In the integration settings page, go to the "Capabilities" tab.
|
||||
2. Enable the required capabilities for your integration. For example:
|
||||
- If your integration needs to read data from Notion, enable the "Read content" capability.
|
||||
- If your integration needs to create new content in Notion, enable the "Insert content" capability.
|
||||
- If your integration needs to update existing content in Notion, enable the "Update content" capability.
|
||||
3. Configure the user information access level based on your integration's requirements.
|
||||
4. Save the changes.
|
||||
|
||||
## Step 3: Obtain Integration Token
|
||||
|
||||
To authenticate your integration with Notion, you need to obtain an integration token.
|
||||
|
||||
1. In the integration settings page, go to the "Secrets" tab.
|
||||
2. Copy the "Internal Integration Token" value. This token will be used to authenticate your integration with Notion.
|
||||
|
||||
<Admonition type="warning" title="Keep Your Token Secure">
|
||||
Your integration token is a sensitive piece of information. Make sure to keep it secure and never share it publicly. Store it safely in your Langflow configuration or environment variables.
|
||||
</Admonition>
|
||||
|
||||
## Step 4: Grant Integration Access to Notion Databases
|
||||
|
||||
For your integration to interact with Notion databases, you need to grant it access to the specific databases it will be working with.
|
||||
|
||||
1. Open the Notion database that you want your integration to access.
|
||||
2. Click on the "Share" button in the top-right corner of the page.
|
||||
3. In the "Invite" section, select your integration from the list.
|
||||
4. Click "Invite" to grant the integration access to the database.
|
||||
|
||||
<Admonition type="info" title="Nested Databases">
|
||||
If your database contains references to other databases, you need to grant the integration access to those referenced databases as well. Repeat step 4 for each referenced database to ensure your integration has the necessary access.
|
||||
</Admonition>
|
||||
|
||||
## Using Notion Components in Langflow
|
||||
|
||||
Once you have set up your Notion integration and granted it access to the required databases, you can start using the Notion components in Langflow.
|
||||
|
||||
Langflow provides the following Notion components:
|
||||
|
||||
- **List Pages**: Retrieves a list of pages from a Notion database.
|
||||
- **List Database Properties**: Retrieves the properties of a Notion database.
|
||||
- **Add Page Content**: Adds content to a Notion page.
|
||||
- **List Users**: Retrieves a list of users with access to a Notion workspace.
|
||||
- **Update Property**: Updates the value of a property in a Notion page.
|
||||
|
||||
Refer to the individual component documentation for more details on how to use each component in your Langflow flows.
|
||||
|
||||
## Additional Resources
|
||||
|
||||
- [Notion API Documentation](https://developers.notion.com/docs/getting-started)
|
||||
- [Notion Integration Capabilities](https://developers.notion.com/reference/capabilities)
|
||||
|
||||
If you encounter any issues or have questions, please reach out to our support team or consult the Langflow community forums.
|
||||
Loading…
Add table
Add a link
Reference in a new issue